2

After @react-native-firebase updated their libraries I'm getting this error when running my react native project for android

react-native-firebase_messaging:compileReleaseJavaWithJavac

I googled and tried some changes I found on the internet but nothing worked.

Can anyone help me with this?

My dependencies:

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

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


    implementation 'androidx.multidex:multidex:2.0.1'

My buildscript:

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: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
    }
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Paulo Rodrigues
  • 397
  • 4
  • 20

2 Answers2

0

I had the same error while building , i was able to solve it by upgrading my Android Studio . This error is happened most of the time because of the version of your JDK.

Amir Doreh
  • 1,369
  • 1
  • 13
  • 25
0

For compile and target SDK version 30, you can use JDK8 and things will work. If you use compile or target SDK version 31 you must upgrade your tools to JDK11 everywhere. It happens frequently that people think they have done that but their gradle build is using an unexpected version of the JDK and still getting 8. All I can say is: update all places to JDK11 and make sure it is actually in use, and in combination with a compile SDK of 31 and a target SDK of 30 (I can't recommend 31 yet unless you test it thoroughly! many modules are still working or support it) things should work

To change the compilesdkversion = 30 to 31, run this command

brew install --cask adoptopenjdk/openjdk/adoptopenjdk11

Smart Samuel
  • 51
  • 1
  • 2