I get an error when building on android with react-native 0.69.x version
Screenshots
$ yarn android
Task :react-native-change-icon:compileDebugKotlin FAILED
...
What went wrong:
Execution failed for task ':react-native-change-icon:compileDebugKotlin'.
> Compilation error. See log for more details
BUILD FAILED in 6s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /Users/yuta/.gradle/caches/transforms-3/1840f47a1b873fd57b507cdcc7f7d5e8/transformed/jetified-react-native-0.69.3-debug-api.jar!/META-INF/ReactAndroid_debug.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
e: /Users/yuta/.gradle/caches/transforms-3/5d5c005847cf8de15717b495cdeb2994/transformed/jetified-kotlin-stdlib-jdk7-1.6.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
e: /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
e: /Users/yuta/.gradle/caches/transforms-3/f9029077105ee094cb660a998bc51080/transformed/jetified-kotlin-stdlib-jdk8-1.6.10.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
e: /Users/yuta/.gradle/caches/transforms-3/fef35b89e5e15dc545425cdee6369ba0/transformed/jetified-kotlin-stdlib-common-1.6.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (15, 54): Unresolved reference: mutableListOf
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (25, 44): Unresolved reference: isEmpty
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (26, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (29, 28): Unresolved reference: isEmpty
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (29, 39): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (32, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (35, 17): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (36, 33): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (42, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (43, 30): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (44, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (53, 25): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (54, 37): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (60, 25): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (61, 11): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconModule.kt: (66, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
The class is loaded from /Users/yuta/.gradle/caches/transforms-3/b4bd8b2d8b84f89e1b1eb3315da16eb4/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconPackage.kt: (10, 16): Unresolved reference: listOf
e: /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/react-native-change-icon/android/src/main/java/com/reactnativechangeicon/ChangeIconPackage.kt: (14, 16): Unresolved reference: emptyList
FAILURE: Build failed with an exception.
BUILD FAILED in 6s
at makeError (/Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/execa/index.js:174:9)
at /Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/yuta/develop/native/react-native-change-launch-icon-app/node_modules/@react-native-community/cli/build/index.js:192:9)
Versions
react-native: 0.69.3
react-native-change-icon: 3.2.0
Solution
Adding kotlinVersion to Android/build.gradle solved the problem!
// android/build.gradle
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
kotlinVersion = "1.5.20" // <- Add
}
..
Platform
Description
I get an error when building on android with react-native 0.69.x version
Screenshots
Versions
Solution Adding kotlinVersion to Android/build.gradle solved the problem!