React-native-firebase: cannot find symbol BuildConfig.APPLICATION_ID

Created on 28 Feb 2020  路  38Comments  路  Source: invertase/react-native-firebase


Issue



Describe your issue here

node_modules@react-native-firebase\app\android\src\reactnative\java\io\invertase\firebase\app\ReactNativeFirebaseAppInitProvider.java:25: error: cannot find symbol
    BuildConfig.APPLICATION_ID + ".reactnativefirebaseappinitprovider";
               ^
  symbol:   variable APPLICATION_ID
  location: class BuildConfig
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':@react-native-firebase_app:compileDebugJavaWithJavac'.

Project Files






Javascript

Click To Expand

#### `package.json`:

# N/A
{
  "name": "appname_mobile",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "postinstall": "npx rn-nodeify --install \"fs, util, path, tls, stream,buffer,global,process\" --hack  \"node ./android-release-gradle-fix.js\"",
    "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'"
  },
  "dependencies": {
    "@react-native-community/async-storage": "1.7.1",
    "@react-native-firebase/analytics": "^6.3.4",
    "@react-native-firebase/app": "^6.3.4",
    "@react-native-firebase/crashlytics": "^6.3.4",
    "asyncstorage-down": "^4.2.0",
    "aws-iot-device-sdk": "^2.2.1",
    "aws-sdk": "^2.601.0",
    "axios": "0.19.0",
    "buffer": "^4.9.1",
    "events": "^3.1.0",
    "native-base": "^2.13.8",
    "path-browserify": "0.0.0",
    "process": "^0.11.10",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-appearance": "0.3.1",
    "react-native-check-box": "^2.1.7",
    "react-native-config": "^0.12.0",
    "react-native-confirmation-code-input": "1.0.4",
    "react-native-dashed-progress": "^1.0.1",
    "react-native-fs": "^2.16.6",
    "react-native-gesture-handler": "^1.5.2",
    "react-native-level-fs": "^3.0.1",
    "react-native-localization": "2.1.6",
    "react-native-logs": "^2.0.0",
    "react-native-modal": "^11.5.3",
    "react-native-paper": "^3.5.1",
    "react-native-reanimated": "^1.4.0",
    "react-native-slider": "^0.11.0",
    "react-native-splash-screen": "^3.2.0",
    "react-native-tab-view": "^2.11.0",
    "react-native-uuid": "^1.4.9",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "4.0.10",
    "react-navigation-stack": "1.10.3",
    "react-navigation-tabs": "2.6.2",
    "react-redux": "^7.1.3",
    "readable-stream": "^1.0.33",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "reselect": "^4.0.0",
    "rn-nodeify": "^10.2.0",
    "stream-browserify": "^1.0.0",
    "util": "^0.10.4"
  },
  "devDependencies": {
    "@babel/core": "^7.7.4",
    "@babel/runtime": "^7.7.4",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.7.2",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.57.0",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "react-native": {
    "path": "path-browserify",
    "fs": "react-native-level-fs",
    "_stream_transform": "readable-stream/transform",
    "_stream_readable": "readable-stream/readable",
    "_stream_writable": "readable-stream/writable",
    "_stream_duplex": "readable-stream/duplex",
    "_stream_passthrough": "readable-stream/passthrough",
    "stream": "stream-browserify",
    "tls": false
  },
  "browser": {
    "path": "path-browserify",
    "fs": "react-native-level-fs",
    "_stream_transform": "readable-stream/transform",
    "_stream_readable": "readable-stream/readable",
    "_stream_writable": "readable-stream/writable",
    "_stream_duplex": "readable-stream/duplex",
    "_stream_passthrough": "readable-stream/passthrough",
    "stream": "stream-browserify",
    "tls": false
  }
}

#### `firebase.json` for react-native-firebase v6:
# N/A
### iOS
Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:

# N/A
#### `AppDelegate.m`:
// N/A


Android

Click To Expand

#### Have you converted to AndroidX? - [x ] my application is an AndroidX application? - [x ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:

apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
.
.
.
dependencies {
    implementation project(':react-native-splash-screen')
    implementation project(path: ":@react-native-firebase_app")
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'


    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}
#### `android/app/build.gradle`:
buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0-alpha09'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta02'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->


Environment

Click To Expand

**`react-native info` output:**

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\<path to project>\node_modules\@react-native-firebase\app\android\src\reactnative\java\io\invertase\firebase\app\ReactNativeFirebaseAppInitProvider.java:25: error: cannot find symbol
    BuildConfig.APPLICATION_ID + ".reactnativefirebaseappinitprovider";
               ^
  symbol:   variable APPLICATION_ID
  location: class BuildConfig
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':@react-native-firebase_app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
- **Platform that you're experiencing the issue on**: - [ ] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `6.3.4` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `N` & `VERSION`




Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

Android General Build Error Android >= 6

Most helpful comment

@mikehardy seems like it should be enough to rename APPLICATION_ID to LIBRARY_PACKAGE_NAME in /app/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppInitProvider.java, as referred here https://android.googlesource.com/platform/tools/base/+/51644d6f302ea8c3616d98afde0b4ee30d7d4741

All 38 comments

This seems like something is very wrong with your build classpaths somehow, I've never seen that symbol not be present. Can you try cloning this repo and running this script to create a throwaway example that should build and run to make sure everything is working on your machine? https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh

That script gets exercised all the time here troubleshooting so it should work, if not something is off on your machine, and if it does work then maybe the comparison between the generated example and your project might be illuminating?

The script worked. I will compare the generated example with my project and share results here.

Downgraded build tools, gradle wrapper :

  1. Build tools version androidbuild.gradle
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
        ....
    }
  1. Gradle wrapper androidgradlewrappergradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip

Same issue, downgrading gradle is working fine

Why closed? Problem is still exists, we cant upgrade gradle now.

Downgrading versions is not solution. Please provide proper solution.

My apologies for the mistake, @narmiel 馃槄

"please provide a proper solution" -> Please provide a minimal reproducable example

I provide a minimal reproducible example above that anyone can run and it works. We can't reproduce this, so there is no action for us?

Code link: https://github.com/ParitoshVaidya/rnfirebase-issue3254

The code is not working after downgrading as well. Checking it...

This gradle plugin is being used with Android Studio 4.0 Canary

I get that, but have you tried with stable? Seems like discovering build bugs with the alpha version of a build infrastructure component is not surprising and likely not our fault? Like, perhaps the new alpha software has things you need to change for it to work? https://developer.android.com/studio/preview/features/#buildfeatures

I believe the link above has the answer to this

May require some sort of documentation update on our part though, hard to say while it's still in alpha as that means (by definition of "alpha") that things can still change. Once it hits beta we can make a concrete decision on how to message it. I imagine it will be across the entire react-native ecosystem - e.g. in the android template for the react-native distribution in general - that this will need a change, and until then it should be noted that gradle plugin >= 4.x is not supported without handling the breaking change (assuming that link above is the root cause)

gradle:4.0.0-beta02 is already out and the project can not complete build process with it.

I am using multiple libraries in my project, but I got this issue of BuildConfig.APPLICATION_ID with rnfirebase on build:gradle:4.0.0-alpha09.

@mikehardy as you already mentioned about upcoming updates to Android SDK, and related changes to RN, you can take up the call to mark this issue with some other label.

@Salakar something blows up on Android Studio 4 beta toolchain. Not live yet but I'm sure it'll be a a few issues all at once when it does, or just this one now with some time to fix...I'm out of time for a little bit as we're on lockdown here which means I'm instantly a homeschool teacher instead of a programmer :-/

Thanks @mikehardy for investigating.

We could probably just refactor this not to rely on BuildConfig, I think there's an underlying gradle change where sub projects no longer have application id generated into the build config.

We can switch this out for Context.getPackageName() in the base class, should solve the issue. PRs welcome otherwise we'll get to this as soon as possible.

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

I think this is related to deprecation of APPLICATION_ID for libraries
https://android.googlesource.com/platform/tools/base/+/51644d6f302ea8c3616d98afde0b4ee30d7d4741

bump

@eatmedev thanks for grabbing my attention? Have anything to add? A PR?

@mikehardy seems like it should be enough to rename APPLICATION_ID to LIBRARY_PACKAGE_NAME in /app/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppInitProvider.java, as referred here https://android.googlesource.com/platform/tools/base/+/51644d6f302ea8c3616d98afde0b4ee30d7d4741

@rolfb it appears if you refactor this like so in a PR:

We can switch this out for Context.getPackageName() in the base class, should solve the issue. PRs welcome otherwise we'll get to this as soon as possible.

..we'll be all set

@mikehardy I get what you are saying, but I don't feel comfortable enough with the Android code to attempt this refactoring. The next best thing I could do was offering a possible quickfix and get feedback on its validity as a fix as I wasn't able to verify if the value was correctly set, just that building my app stopped complaining about it. Sorry.

@rolfb - okay but I don't think that's actually a valid solution. You want the provider name to be based on the app name not the library name (it's not really a library? it becomes part of your app?) so while it can work with a quick fix, I think the proposed change from @Salakar is the ticket if someone can post it up as a PR

Thanks for explaining. @Salakar鈥檚 solution does seem like the way to go.

New release is out with this, just in time for Android Studio 4!

Where can I find the released version with this fix?
The latest available version on npm of @react-native-firebase/app 7.1.0 was published 7 days ago.

Oh boy, looks like CI failed 馃檲 looking into it

I installed @react-native-firebase/app 7.1.0, but the issue is still there.

@seriousStar as mentioned just above your comment there was a problem with the CI. The fix is in upcoming version 7.1.1.

I've manually released them for now while I'm looking into CI, latest is 7.1.2.

There may be a few more patch releases appearing but this is me just sorting CI out.

Ok CI sorted; added a few patch releases unfortunately but no big deal - there's no changes in them.

Latest packages;

{
    "@react-native-firebase/admob": "7.1.2",
    "@react-native-firebase/analytics": "7.1.2",
    "@react-native-firebase/app": "7.1.4",
    "@react-native-firebase/auth": "8.0.2",
    "@react-native-firebase/crashlytics": "7.1.3",
    "@react-native-firebase/database": "7.1.2",
    "@react-native-firebase/dynamic-links": "7.1.2",
    "@react-native-firebase/firestore": "7.1.2",
    "@react-native-firebase/functions": "7.1.2",
    "@react-native-firebase/iid": "7.1.2",
    "@react-native-firebase/in-app-messaging": "7.1.2",
    "@react-native-firebase/messaging": "7.1.3",
    "@react-native-firebase/ml-natural-language": "7.1.2",
    "@react-native-firebase/ml-vision": "7.1.2",
    "@react-native-firebase/perf": "7.1.2",
    "@react-native-firebase/remote-config": "7.1.2",
    "@react-native-firebase/storage": "7.1.2",
}

Ok CI sorted; added a few patch releases unfortunately but no big deal - there's no changes in them.

Latest packages;

{
    "@react-native-firebase/admob": "7.1.2",
    "@react-native-firebase/analytics": "7.1.2",
    "@react-native-firebase/app": "7.1.4",
    "@react-native-firebase/auth": "8.0.2",
    "@react-native-firebase/crashlytics": "7.1.3",
    "@react-native-firebase/database": "7.1.2",
    "@react-native-firebase/dynamic-links": "7.1.2",
    "@react-native-firebase/firestore": "7.1.2",
    "@react-native-firebase/functions": "7.1.2",
    "@react-native-firebase/iid": "7.1.2",
    "@react-native-firebase/in-app-messaging": "7.1.2",
    "@react-native-firebase/messaging": "7.1.3",
    "@react-native-firebase/ml-natural-language": "7.1.2",
    "@react-native-firebase/ml-vision": "7.1.2",
    "@react-native-firebase/perf": "7.1.2",
    "@react-native-firebase/remote-config": "7.1.2",
    "@react-native-firebase/storage": "7.1.2",
}

how do i install these new versions
when i install it works fine on android but when i run pod install i get an error

[!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
  In snapshot (Podfile.lock):
    Firebase/CoreOnly (= 6.13.0)

  In Podfile:
    RNFBApp (from `../node_modules/@react-native-firebase/app`) was resolved to 7.1.4, which depends on
      Firebase/CoreOnly (~> 6.25.0)


Delete Podfile.lock and re-run pod install I think is the general recommendation, assuming your javascript packages are up to date (e.g. yarn update --latest)

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `Firebase/CoreOnly` inside your development pod `RNFBApp`.
   You should run `pod update Firebase/CoreOnly` to apply changes you've made.

@arichayo the error message gave you the fix - run pod update Firebase/CoreOnly

Use BuildConfig.LIBRARY_PACKAGE_NAME

BuildConfig: Deprecate APPLICATION_ID in libraries.

It is at best misleading, so it is marked as deprecated and replaced by
LIBRARY_PACKAGE_NAME.

https://android.googlesource.com/platform/tools/base/+/51644d6f302ea8c3616d98afde0b4ee30d7d4741

Downgraded build tools, gradle wrapper :

this solution worked for me. thank you man

thanks so much @rolfb you my hero :)

Was this page helpful?
0 / 5 - 0 ratings