Home > Mobile >  @react-native-firebase_app: Cannot get property 'android'
@react-native-firebase_app: Cannot get property 'android'

Time:12-08

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

CodePudding user response:

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

CodePudding user response:

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;
}
  • Related