Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin 1.9.0: npm package build fails #3267

Closed
petriaarnio opened this issue Dec 13, 2023 · 16 comments · Fixed by #3461
Closed

kotlin 1.9.0: npm package build fails #3267

petriaarnio opened this issue Dec 13, 2023 · 16 comments · Fixed by #3461

Comments

@petriaarnio
Copy link

Environment

  • Dev OS: macOS 13.5.2
  • @rnmapbox/maps version: 10.1.1
  • React Native version: 0.72.4

Steps to reproduce

  1. npm install @rnmapbox/maps
  2. npm run android

Error:
e: file:///Users/xxx/work/mobile/mobile_app/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/AbstractEventEmitter.kt:53:5 'addEventEmitters' overrides nothing

@mfazekas
Copy link
Contributor

It's interesting as according to https://github.com/facebook/react-native/blame/746ad378c7efe3ee2f4926ab30e5401407f8b3ba/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java#L242

superclass of AbstractEventEmitter - ViewManager in react-native had the

  protected void addEventEmitters(@NonNull ThemedReactContext reactContext, @NonNull T view) {}

Unchanged for for years.
So not sure why the compiler error.

@petriaarnio
Copy link
Author

Yes, this is strange.
I tried the same with "vanilla" project and it compiles ok.
So my project has something which causes the compilation error. Just hard to figure out what it is.

@mfazekas
Copy link
Contributor

My 2 tips, is either your react-native version. - check content of ViewManager.java. Or your kotlin settings in your Gradle files?

@mfazekas
Copy link
Contributor

I'm closing this as this sound project specific then.

@mfazekas mfazekas closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2023
@rayjackson13
Copy link

I ran into the exact same issue on my project.

Environment:

  • React Native: 0.72.4
  • @rnmapbox/maps: 10.1.15
  • kotlinVersion: 1.9.0
  • Gradle: 8.0.1

Downgrading Kotlin version to 1.8.0 helped resolve this:

buildscript {
    ext {
       ...
        kotlinVersion = '1.8.0'
    }
    ...
    dependencies {
       ...
        classpath('org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0')
     }
}

Hope this helps :)

@mfazekas mfazekas changed the title npm package build fails kotlin 1.9.0: npm package build fails Feb 26, 2024
@mfazekas mfazekas reopened this Feb 26, 2024
@petriaarnio
Copy link
Author

I got this working after upgraded react-native to version 0.73.1
They also switched to Kotlin.

@robin-pham
Copy link
Contributor

Proposed a PR fix that worked for me, should be an easy patch if anyone else needs to implement it ASAP. Got the inspiration from invertase/react-native-google-mobile-ads#511

@MinskLeo
Copy link

Any progress there? The fix is easy to apply, but would be good to have working lib release without applying additional patch.

@petriaarnio
Copy link
Author

petriaarnio commented Apr 27, 2024

Like I mentioned earlier, the problem disappeared with the latest React native version. Did not need any patch.

@andreirat
Copy link

andreirat commented May 8, 2024

@mfazekas I just encountered a similar issue, Android build fails after mapbox upgrade.

"react-native": "0.72.14",
"@rnmapbox/maps": "^10.1.21",

e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /Users/runner/.gradle/caches/transforms-3/49101a29b9e4fb48ee2b093f44617f88/transformed/jetified-kotlinx-coroutines-android-1.8.0.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
e: /Users/runner/.gradle/caches/transforms-3/7fc092dbf0c43219afef390baa06b7b3/transformed/jetified-kotlin-stdlib-1.9.21.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.9.0, expected version is 1.6.0.
e: /Users/runner/.gradle/caches/transforms-3/7fc092dbf0c43219afef390baa06b7b3/transformed/jetified-kotlin-stdlib-1.9.21.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.9.0, expected version is 1.6.0.
e: /Users/runner/.gradle/caches/transforms-3/7fc092dbf0c43219afef390baa06b7b3/transformed/jetified-kotlin-stdlib-1.9.21.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
e: /Users/runner/.gradle/caches/transforms-3/9134c1c30b1a5b9ad37dd095f699d011/transformed/jetified-kotlinx-coroutines-core-jvm-1.8.0.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.

e: /Users/runner/work/1/s/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt: (67, 18): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
The class is loaded from /Users/runner/.gradle/caches/transforms-3/7fc092dbf0c43219afef390baa06b7b3/transformed/jetified-kotlin-stdlib-1.9.21.jar!/kotlin/Unit.class
e: /Users/runner/work/1/s/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt: (78, 18): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
The class is loaded from /Users/runner/.gradle/caches/transforms-3/7fc092dbf0c43219afef390baa06b7b3/transformed/jetified-kotlin-stdlib-1.9.21.jar!/kotlin/Unit.class
e: /Users/runner/work/1/s/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt: (85, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.

@mfazekas
Copy link
Contributor

mfazekas commented May 8, 2024

@andreirat That is a bit different issue. See https://github.com/rnmapbox/maps/pull/3465/files

You might be able to work around that using

kotlinxCoroutinesCoreVersion = 1.6.4
kotlinxCoroutinesAndroidVersion = 1.6.4

Add this to your andorid/build.gradle file after kotlinVersion = 1.6... in buildscript { ext {

@andreirat
Copy link

@andreirat That is a bit different issue. See https://github.com/rnmapbox/maps/pull/3465/files

You might be able to work around that using

kotlinxCoroutinesCoreVersion = 1.6.4
kotlinxCoroutinesAndroidVersion = 1.6.4

Add this to your andorid/build.gradle file after kotlinVersion = 1.6... in buildscript { ext {

@mfazekas already did that, but it would break other packages we are using. It worked with RN version 0.72.4.

@mfazekas
Copy link
Contributor

mfazekas commented May 8, 2024

@andreirat why did it break other packages? Which ones?

@andreirat
Copy link

@mfazekas

  • datadog
  • react-native-screens
  • mapbox still throws this
The class is loaded from /Users/andreirat/.gradle/caches/transforms-3/5d727cf8e0ce4b87b50c99126e24b794/transformed/jetified-kotlin-stdlib-1.9.21.jar!/kotlin/Unit.class
e: /Users/andreirat/projects/Rodeo/rodeo/node_modules/@rnmapbox/maps/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/v11compat/StyleFactory.kt: (16, 10): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
The class is loaded from /Users/andreirat/.gradle/caches/transforms-3/5d727cf8e0ce4b87b50c99126e24b794/transformed/jetified-kotlin-stdlib-1.9.21.jar!/kotlin/Unit.class
e: /Users/andreirat/projects/Rodeo/rodeo/node_modules/@rnmapbox/maps/android/src/main/mapbox-v11-compat/v10/com/rnmapbox/rnmbx/v11compat/StyleFactory.kt: (20, 5): Unresolved reference:

@andreirat
Copy link

@mfazekas downgraded to "@rnmapbox/maps": "10.1.17", and the build works. I wonder if this version covers all the Apple Privacy warnings?

@disersoft-code
Copy link

I had the same issue that @andreirat, Environment:

  • React Native: 0.72.6
  • @rnmapbox/maps: 10.1.21
  • kotlinVersion: 1.9.0

and downgraded to @rnmapbox/maps: 10.1.17, and it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants