React-native-firebase: Execution failed for task ':react-native-firebase:compileDebugJavaWithJavac'.

Created on 2 May 2019  路  9Comments  路  Source: invertase/react-native-firebase

My Android project has error, after configure react-native-firebase.

Error:

org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':react-native-firebase:compileDebugJavaWithJavac'.
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:154)
at .....

My 'app/build.gradle':

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.xxx"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        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:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

apply plugin: 'com.google.gms.google-services'

dependencies {
    //implementation project(':react-native-device-info')
    implementation project(':react-native-google-places')
    compile project(':react-native-autogrow-textinput')
    compile(project(':react-native-firebase')) {
        transitive = false
    }
    compile (project(':react-native-device-info')){
        exclude group: "com.google.android.gms"
    }
    compile ("com.google.android.gms:play-services-location:15.0.1") {
        force = true;
    }
    compile ("com.google.android.gms:play-services-places:15.0.1") {
        force = true;
    }
    compile ("com.google.android.gms:play-services-base:15.0.1") {
        force = true;
    }
    compile ("com.google.android.gms:play-services-maps:15.0.1") {
        force = true;
    }
    compile ("com.google.android.gms:play-services-gcm:15.0.1") {
        force = true;
    }
    compile ('com.google.firebase:firebase-core:15.0.2') {
        force = true;
    }
    compile ('com.google.firebase:firebase-messaging:15.0.2') {
        force = true;
    }
    compile project(':react-native-linear-gradient')
    compile project(':react-native-image-picker')
    compile project(':react-native-fbsdk')
    compile project(':react-native-vector-icons')
    compile project(':react-native-gesture-handler')
    compile project(':react-native-geolocation-service')
    compile project(':react-native-linear-gradient')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
    //implementation "com.google.android.gms:play-services-base:15.0.0"
    //implementation "com.google.firebase:firebase-core:15.0.2"
    //implementation "com.google.firebase:firebase-messaging:15.0.2"
    implementation project(':react-native-fbsdk')
}
apply plugin: 'com.google.gms.google-services'  // Google Play services Gradle

// 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'
}

My 'build.gradle' in root:

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
        googlePlayServicesVersion = "11.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.2.0'

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

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

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.1"
            }
        }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

Any solution? I've been having this issue for two days.

Thanks!!!

Most helpful comment

Reinstall react-native-firebase, here solve the problem...

yarn add react-native-firebase

All 9 comments

those all look like old google play versions, and that force business is bad news - look at the react-native-firebase starter - clone it local and make it run. Then slowly do exactly what it does in your project

I try, but same issue.

more error details, when run 'react-native run-android'.

Task :react-native-firebase:compileDebugJavaWithJavac FAILED
/Users/gabriel/Documents/ufrilla/ufrilla-app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:231: error: cannot find symbol
return createChannelGroupMap(notificationManager.getNotificationChannelGroup(channelGroupId));
^
symbol: method getNotificationChannelGroup(String)
location: variable notificationManager of type NotificationManager
/Users/gabriel/Documents/ufrilla/ufrilla-app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:331: error: cannot find symbol
notificationChannelGroup.setDescription(description);
^
symbol: method setDescription(String)
location: variable notificationChannelGroup of type NotificationChannelGroup
/Users/gabriel/Documents/ufrilla/ufrilla-app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:407: error: cannot find symbol
writableMap.putString("description", notificationChannelGroup.getDescription());
^
symbol: method getDescription()
location: variable notificationChannelGroup of type NotificationChannelGroup
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors

FAILURE: Build failed with an exception.

This doesn't look right. If you are pulling right from the starter, it should work out of the box. Please confirm you just cloned, followed the readme (to change package name and put in a googleservices json) and it works

The error you mention looks related to APIs, like you are still resolving to old Android SDKs that don't have notification channels. Not sure what to say about that but I will be completely surprised if the starter does not work out of the box.

I first took the steps recommended in this #1759
I read @mikehardy's recommendation that force was bad so I went to
./android/build.gradle and commented out all of them.

allprojects {
   ...
        configurations.all {
            resolutionStrategy {
                force "com.google.android.gms:play-services-base:${googlePlayServicesVersion}"
                force "com.google.android.gms:play-services-maps:${googlePlayServicesVersion}"
                force "com.google.firebase:firebase-core:${firebaseMessagingVersion}"
                force "com.google.firebase:firebase-messaging:${firebaseMessagingVersion}"
                force "com.facebook.android:facebook-android-sdk:4.37.0"
            }
        }
}

to

allprojects {
   ...
        configurations.all {
            resolutionStrategy {
                // force "com.google.android.gms:play-services-base:${googlePlayServicesVersion}"
                // force "com.google.android.gms:play-services-maps:${googlePlayServicesVersion}"
                // force "com.google.firebase:firebase-core:${firebaseMessagingVersion}"
                // force "com.google.firebase:firebase-messaging:${firebaseMessagingVersion}"
                // force "com.facebook.android:facebook-android-sdk:4.37.0"
            }
        }
}

next, in my ./android/app/build.gradle I added the versions manually(as suggested by the command line prompt when I tried to run react-native run-android.

dependencies {
    ...
    implementation("com.google.firebase:firebase-iid:18.0.0")
    implementation("com.google.firebase:firebase-iid-interop:16.0.1")
    implementation("com.google.firebase:firebase-common:17.0.0")
    implementation("com.google.firebase:firebase-measurement-connector:17.0.1")
    implementation("com.google.android.gms:play-services-stats:16.0.1")
    implementation("com.google.firebase:firebase-messaging:18.0.0")
    ...
}

After these steps, I was able to build. Hope this helps~!

Just adding my two cents, have had an app building with these libs since December; last week made some API upgrades and the app still built. Today, with no other changes, the app has just stopped building with the same issues. Not sure if there's some deprecation date we've hit or something but literally code that built Friday now won't build with these errors.

I am attempting a fix so will report back in a new comment with anything that works.

I resolved this following advice from @VitorBrangioni

I wasn't 100% about which change fixed it; just altering the implementation versions didn't so I suspect it was the API versions. Here's my git diff that resolved it, in case it helps anyone else

--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@
 android {
-    compileSdkVersion 27
+    compileSdkVersion rootProject.ext.compileSdkVersion

     defaultConfig {
         applicationId "com.xxxxx.mobile"
-        minSdkVersion 21
-        targetSdkVersion 27
+        minSdkVersion rootProject.ext.minSdkVersion
+        targetSdkVersion rootProject.ext.targetSdkVersion

@@  android {
         }
     }
     compileOptions {
+       sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
     }
 }

@@

-    implementation 'com.google.android.gms:play-services-base:16.0.1'
-    implementation 'com.google.firebase:firebase-core:16.0.6'
-    implementation 'com.google.firebase:firebase-messaging:17.3.4'
+    implementation 'com.google.android.gms:play-services-base:16.1.0'
+    implementation 'com.google.firebase:firebase-core:16.0.8'
+    implementation 'com.google.firebase:firebase-messaging:17.5.0'

--- a/android/build.gradle
+++ b/android/build.gradle
@@
buildscript {
    ext {
        googlePlayServicesVersion = "16.1.0"
-        minSdkVersion = 16
-        compileSdkVersion = 27
-        targetSdkVersion = 27
+        minSdkVersion = 21
+        compileSdkVersion = 28
+        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
     }
 }

Reinstall react-native-firebase, here solve the problem...

yarn add react-native-firebase

So I had the same issue and turns out it was because of AndroidX. A lot of import statements were wrong. (in react-native-firebase)

I found the errors using 'Make Project' in Android Studio and then corrected them using the ClassMappings provided in the docs.

Finally ./gradlew assembleRelease worked!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitfabrikken picture bitfabrikken  路  52Comments

tranty9597 picture tranty9597  路  79Comments

jasan-s picture jasan-s  路  137Comments

kevinEsherick picture kevinEsherick  路  57Comments

umang-simform picture umang-simform  路  77Comments