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

Unable to build v3.26.0 on Android #1931

Closed
short-dsb opened this issue Oct 18, 2023 · 15 comments
Closed

Unable to build v3.26.0 on Android #1931

short-dsb opened this issue Oct 18, 2023 · 15 comments
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android

Comments

@short-dsb
Copy link

Description

Release v3.25.0 works fine, but v3.26.0 fails to build for Android (iOS builds successfully).

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.io.path.DirectoryEntriesReader found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.ExperimentalPathApi found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.FileVisitorBuilder found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.FileVisitorBuilderImpl found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.FileVisitorImpl found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.LinkFollowing found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathNode found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathRelativizer found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathTreeWalk found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathTreeWalk$bfsIterator$1 found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathTreeWalk$dfsIterator$1 found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathTreeWalkKt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathWalkOption found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathsKt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathsKt__PathReadWriteKt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathsKt__PathUtilsKt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.jdk7.AutoCloseableKt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.jvm.optionals.OptionalsKt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)
     Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and jetified-kotlin-stdlib-jdk8-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.22)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-screens:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

Steps to reproduce

  1. npm run react-native run-android

Snack or a link to a repository

N/A, build issue and private repo

Screens version

3.26.0

React Native version

0.72.6

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Android emulator

Device model

Pixel 6 Pro (API 32)

Acknowledgements

Yes

@github-actions github-actions bot added the Platform: Android This issue is specific to Android label Oct 18, 2023
@github-actions
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added the Missing repro This issue need minimum repro scenario label Oct 18, 2023
@bhandanyan-nomad
Copy link

Same issue here, React Native 0.70.13

@kkafar
Copy link
Member

kkafar commented Oct 18, 2023

CI is passing & it works for me locally. W/o reproduction we can't do much.

@short-dsb
Copy link
Author

Unfortunately, our project is in a private repo so I can’t provide a link. I’ll try to create a minimum reproduction if I can find the time.

@bhandanyan-nomad
Copy link

Looking into my errors further, seems I'm getting a different error. This is from a production build which could be the reason for the different errors.

Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

Hopefully this is helpful. My repo is also private so it cannot be shared.

@short-dsb
Copy link
Author

Looks like the Kotlin version was changed in v3.26.0 (see example). I had to update my Kotlin version to match the example, and add the kotlion-gradle-plugin with that version to my build.gradle.

diff --git a/android/build.gradle b/android/build.gradle
index acc9e057..86a99482 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -6,7 +6,7 @@ buildscript {
         minSdkVersion = 21
         compileSdkVersion = 33
         targetSdkVersion = 33
-        kotlinVersion = "1.6.21"
+        kotlinVersion = "1.8.22"

         // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
         ndkVersion = "23.1.7779620"
@@ -18,6 +18,7 @@ buildscript {
     dependencies {
         classpath("com.android.tools.build:gradle")
         classpath("com.facebook.react:react-native-gradle-plugin")
+        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
         classpath('com.google.gms:google-services:4.3.14')
         classpath('com.google.firebase:firebase-crashlytics-gradle:2.2.0')
         // NOTE: Do not place your application dependencies here; they belong

After this, the Android build completed successfully.

Note that this version of Kotlin is different than what is used in the v0.73.0 template, so this may be an issue once that release is final.

@short-dsb
Copy link
Author

@kkafar Thanks for taking a look!

@kkafar
Copy link
Member

kkafar commented Oct 18, 2023

react-native-screens uses 1.8.0 since 3.26.0 by default (this is the same that is used in new template), however if you specify kotlin version in your application (which is the case in vast majority of cases) then it is also used to compile screens. Thus I do not really understand the error, but I'm happy it works :D

@eduardo-santos-tribia
Copy link

eduardo-santos-tribia commented Oct 19, 2023

Why this kotlinVersion update is not a breaking change in the release notes? I'm having the same issue here, but I can't bump kotlinVersion because of another library dependency.

@kkafar
Copy link
Member

kkafar commented Oct 19, 2023

I can only cite myself

CI is passing & it works for me locally. W/o reproduction we can't do much.

also:

react-native-screens uses 1.8.0 since 3.26.0 by default (this is the same that is used in new template), however if you specify kotlin version in your application (which is the case in vast majority of cases) then it is also used to compile screens.

@eduardo-santos-tribia
Copy link

@kkafar Is there any other solution without setting the kotlinVersion to > 1.8? I have another library dependency and can't update now to 1.8.

@kkafar
Copy link
Member

kkafar commented Oct 20, 2023

You can stick to react-native-screens@3.25.0 for now (set this in your package.json). I can't advise anything more as I've not been able to reproduce the issue.

@kkafar
Copy link
Member

kkafar commented Oct 20, 2023

I've reproduced the issue finally -> I had bumped androidx.fragment to 1.6.1 and it depends on libs that require higher Kotlin version. I'll release new version on Monday if nothing new popups.

@tboba
Copy link
Member

tboba commented Oct 24, 2023

Hey @short-dsb @bhandanyan-nomad @eduardo-santos-tribia! Just wanna announce that we're released react-native-screens 3.27.0 which includes the fix for that issue! 🎉
If you're still facing any problems in the newest version, don't hesitate to open a new issue 🙏

Cheers!

@bhandanyan-nomad
Copy link

Opened new issue:
#1947

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android
Projects
None yet
Development

No branches or pull requests

5 participants