MoEngage Project Can't Compiled on React Native 0.73.2 and Java 17

104 views Asked by At

I have a react native 0.73.2 and working on MoEngage integration. The React Native version of MoEngage installed is 8.6.0 while the android sdk version is com.moengage:moe-android-sdk:12.10.02.

My React Native project is using Java 17 and there's an error while compiling the app:

> 'compileDebugJavaWithJavac' task (current target is 17) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain * Try:

So, I update my (app) build.gradle

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }

The problem persist, I still can't compile the app.

1

There are 1 answers

1
Leonardo Santos On

I had the same problem, this worked for me:

build.gradle

android {
  ...

  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
    compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
      jvmTarget = "1.8"
    }
  }
}

References: