skip to Main Content

I’m trying to upgrade a react-native app to 0.70 but I’ve hit a problem when building the app. It fails with the error:

A problem occurred evaluating project ‘:@react-native-firebase_app’.
Cannot get property ‘android’ on null object

It seems to failing in the firebase_analytics/android/build.gradle at this lines:

def packageJson = PackageJson.getForProject(project)

def appPackageJson = PackageJson.getForProject(appProject)

def firebaseBomVersion = appPackageJson[‘sdkVersions’][‘android’][‘firebase’]

as the appPackage[‘sdkVersions’] is null.

settings.gradle

include ':@react-native-firebase_app'
project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, 
'./../node_modules/@react-native-firebase/app/android')
include ':@react-native-firebase_analytics'
project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, 
'../node_modules/@react-native-firebase/analytics/android')

I’m using Node v18, NPM, Java 11. Firebase app and analytics are both version 16.4.6.

If any other settings would help, let me know and I’ll add them to the question.

Thanks

2

Answers


  1. Chosen as BEST ANSWER

    The answer (maybe not the best approach) was to manually link the files the project needed. Instructions below but I would also suggest trying to figure out why your autolinking isn't working (I had no luck).

    settings.gradle:

    include ':react-native-firebase_app'
    project(':react-native-firebase_app').projectDir = new 
    File(rootProject.projectDir, './../node_modules/@react-native- 
    firebase/app/android')
    
    include ':react-native-firebase_analytics'
    project(':react-native-firebase_analytics').projectDir = new 
    File(rootProject.projectDir, '../node_modules/@react-native- 
    firebase/analytics/android')
    

    app/build.gradle

    implementation project(path: ":react-native-firebase_app")
    implementation project(path: ":react-native-firebase_analytics")
    

    MainApplication.java

    import io.invertase.firebase.app.ReactNativeFirebaseAppPackage;
    import io.invertase.firebase.analytics.ReactNativeFirebaseAnalyticsPackage;
    

    and add to the packageslist in the same file:

    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
    
      ...
      packages.add(new ReactNativeFirebaseAppPackage())
      packages.add(new ReactNativeFirebaseAnalyticsPackage());
        
      return packages;
    }
    

  2. Please try to upgrade all @react-native-firebase dependencies to their latest versions using yarn or npm.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search