invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.64k stars 2.21k forks source link

> Task :react-native-firebase_messaging:compileDebugJavaWithJavac FAILED #5724

Closed paulorod07 closed 3 years ago

paulorod07 commented 3 years ago

Issue

Describe your issue here


Project Files

buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 23 compileSdkVersion = 31 targetSdkVersion = 31 kotlinVersion = '1.5.0' ndkVersion = "20.1.5948944" } repositories { google() jcenter() } dependencies { // classpath("com.android.tools.build:gradle:3.5.3") classpath("com.android.tools.build:gradle:4.1.0") classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" classpath 'com.google.gms:google-services:4.3.10' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }

implementation 'com.google.firebase:firebase-analytics'

// implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation platform('com.google.firebase:firebase-bom:28.4.0')
implementation 'com.google.firebase:firebase-messaging'

// implementation 'com.google.firebase:firebase-iid:17.0.2'

implementation 'androidx.multidex:multidex:2.0.1'

Javascript

Click To Expand

#### `package.json`: ```json { "name": "appmozaik", "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 ." }, "dependencies": { "@invertase/react-native-apple-authentication": "^2.1.2", "@microsoft/signalr": "^5.0.5", "@react-native-async-storage/async-storage": "^1.15.4", "@react-native-clipboard/clipboard": "^1.8.4", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/picker": "1.6.0", "@react-native-community/rxjs": "^6.5.4-custom", "@react-native-firebase/app": "^12.0.0", "@react-native-firebase/messaging": "^12.0.0", "@react-navigation/bottom-tabs": "^5.11.10", "@react-navigation/native": "^5.9.4", "@react-navigation/stack": "^5.14.4", "aws-sdk": "^2.771.0", "axios": "^0.21.1", "base64-arraybuffer": "^0.2.0", "cep-promise": "^4.1.0", "expo-constants": "^10.1.3", "expo-notifications": "^0.11.6", "expo-permissions": "^12.0.1", "i18n-js": "^3.8.0", "moment": "^2.29.1", "native-base": "^2.15.2", "react": "17.0.1", "react-native": "0.63.4", "react-native-audio-recorder-player": "^3.1.1", "react-native-azure-auth": "^1.8.1", "react-native-confirmation-code-field": "6", "react-native-crypto-js": "^1.0.0", "react-native-device-info": "^8.1.3", "react-native-document-picker": "^5.2.0", "react-native-exception-handler": "^2.10.10", "react-native-fast-image": "^8.3.4", "react-native-fs": "^2.18.0", "react-native-gesture-handler": "^1.10.3", "react-native-htmlview": "^0.16.0", "react-native-image-picker": "^3.6.0", "react-native-iphone-x-helper": "^1.3.1", "react-native-keyboard-aware-scroll-view": "^0.9.3", "react-native-masked-text": "^1.13.0", "react-native-msal": "^3.1.2", "react-native-permissions": "^3.0.3", "react-native-picker-select": "7.0.0", "react-native-reanimated": "^2.2.0", "react-native-render-html": "^5.1.1", "react-native-responsive-fontsize": "^0.5.0", "react-native-responsive-screen": "^1.4.2", "react-native-safe-area-context": "^3.2.0", "react-native-screens": "^3.1.1", "react-native-snap-carousel": "^3.9.1", "react-native-splash-screen": "^3.2.0", "react-native-status-bar-height": "^2.6.0", "react-native-svg": "^12.1.1", "react-native-svg-charts": "^5.4.0", "react-native-svg-transformer": "^0.14.3", "react-native-unimodules": "^0.13.3", "react-native-vector-icons": "^8.1.0", "react-native-video": "^5.1.1", "react-native-video-controls": "^2.8.1", "react-native-webview": "^11.4.2", "rn-fetch-blob": "^0.12.0", "rn-swipeable-panel": "^1.2.5" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "@testing-library/jest-native": "^4.0.1", "@testing-library/react-native": "^7.2.0", "@types/jest": "^26.0.23", "babel-eslint": "^10.1.0", "babel-jest": "^26.6.3", "eslint": "^7.25.0", "eslint-config-airbnb": "^18.2.1", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-react": "^7.23.2", "eslint-plugin-react-hooks": "^4.2.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.64.0", "prettier": "^2.2.1", "react-test-renderer": "^17.0.2" }, "jest": { "preset": "react-native", "setupFilesAfterEnv": [ "@testing-library/jest-native/extend-expect" ], "setupFiles": [ "./__mocks__/@react-native-async-storage/async-storage", "./__mocks__/jest/setup" ] } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [don't know ] 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`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 23 compileSdkVersion = 31 targetSdkVersion = 31 kotlinVersion = '1.5.0' ndkVersion = "20.1.5948944" } repositories { google() jcenter() } dependencies { // classpath("com.android.tools.build:gradle:3.5.3") classpath("com.android.tools.build:gradle:4.1.0") classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" classpath 'com.google.gms:google-services:4.3.10' // 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://www.jitpack.io' url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1' } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply from: '../../node_modules/react-native-unimodules/gradle.groovy' apply plugin: 'com.google.gms.google-services' import com.android.build.OutputFile project.ext.react = [ enableHermes: false, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); android { ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.code7omni" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 43 versionName "1.1.5" multiDexEnabled true manifestPlaceholders = [ appAuthRedirectScheme: 'io.identityserver.demo' ] } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } release { if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) { storeFile file(MYAPP_UPLOAD_STORE_FILE) storePassword MYAPP_UPLOAD_STORE_PASSWORD keyAlias MYAPP_UPLOAD_KEY_ALIAS keyPassword MYAPP_UPLOAD_KEY_PASSWORD } } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = defaultConfig.versionCode * 1000 + versionCodes.get(abi) } } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation 'com.microsoft.identity.client:msal:2.0.+' implementation "androidx.appcompat:appcompat:1.0.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation 'com.google.firebase:firebase-analytics' // implementation platform('com.google.firebase:firebase-bom:28.0.1') implementation platform('com.google.firebase:firebase-bom:28.4.0') implementation 'com.google.firebase:firebase-messaging' // implementation 'com.google.firebase:firebase-iid:17.0.2' implementation 'androidx.multidex:multidex:2.0.1' compile project(':react-native-exception-handler') addUnimodulesDependencies() implementation project(':react-native-fs') debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } project.ext.vectoricons = [ iconFontNames: [ 'MaterialIcons.ttf', 'Feather.ttf', 'FontAwesome.ttf' ] // Name of the font files you want to copy ] apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **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:** - "@react-native-firebase/app": "^12.8.0", "@react-native-firebase/messaging": "^12.8.0", - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`


mikehardy commented 3 years ago

Hi there, sorry but there are things, like package.json missing from the template that are required to help. Additionally the module compiles fine so I will close this.

Please make sure that you have current versions

Please examine our test app in the tests directory of the repo for versions that work, or this script that is a full example of project integration with comments https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

paulorod07 commented 3 years ago

@mikehardy I updated with my package.json

I am having this error when run on android only

mikehardy commented 3 years ago

Of course, it's an android error, it follows it happens on Android only. My comment stands. The module works. Please examine the material I have provided so that you can fix your project-specific issue

paulorod07 commented 3 years ago

@mikehardy I can't solve it until now :(

mikehardy commented 3 years ago

Insufficient details to help, as mentioned. Run my script.

paulorod07 commented 3 years ago

@mikehardy What directory I need to run your script exactly?

I ran in the root directory of my project but I receive this log: cp: ../GoogleService-Info.plist: No such file or directory

but I have this file in my iOS folder

robertqin86 commented 3 years ago

Hi @paulorod07 , I had the exact same issue that you experienced. I can confirm what @mikehardy says is correct, this is nothing to do with the react-native-firebase_messaging package. If you downgrade to a lower version, you will likely experience the same issue.

This issue is likely caused when you upgraded to Android Studio Artic Fox, but you're still using an older JDK version, and you're trying to build your project using Android Studio. Please upgrade your JDK to use Android Studio Java 11. You can see details of the setup here.

I upgraded my gradle java version in Android Studio and managed to solve this error and produce a release build. Hope this helps and is relevant to your case!

sjonchhe commented 2 years ago

Nothings worked for me so far...I've been stuck with this for more than a month

mikehardy commented 2 years ago

and yet https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh - "just works" 🤔 Honestly, I'm just not sure what to say. The stuff can build. But there are a million ways to have a busted native project Run that script and compare it's java native output with your project. The error is in the difference

jwrubel commented 2 years ago

FWIW I just ran in to this issue and @robertqin86 's advice helped me fix it. I did two things; 1) upgraded Android Studio from Arctic Fox to Bumblebee and 2 followed the directions here to upgrade my JDK. I am not sure which of these did the trick, most likely upgrading the JDK.