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

Gradle issue after upgrading to React Native 0.71.7 #25

Closed
j3lev opened this issue May 4, 2023 · 6 comments · Fixed by #27
Closed

Gradle issue after upgrading to React Native 0.71.7 #25

j3lev opened this issue May 4, 2023 · 6 comments · Fixed by #27

Comments

@j3lev
Copy link

j3lev commented May 4, 2023

Hey there, I've been updating our app to the latest stable RN version 0.71.7 and the new Kotlin version doesn't play nicely with this library and throws the following error:

FAILURE: Build failed with an exception.

* What went wrong:
The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher.
The following dependencies do not satisfy the required version:
project ':amplitude_experiment-react-native-client' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org/

Our solution was to patch the library's build.gradle the following way:

 buildscript {
-    ext.kotlinVersion = "1.5.30"
     repositories {
         google()
         jcenter()
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.5.3'
-        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
+        classpath 'com.android.tools.build:gradle:7.3.1'
     }
 }

This fixed our issue however patching node_modules is definitely sub-optimal. The library should be updated to support the latest stable React Native versions. A possible fix could be implemented similarly to how DataDog defensively initializes their kotlin version:

 def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['DdSdkReactNative_kotlinVersion']
...
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

Thanks!

@bgiori
Copy link
Contributor

bgiori commented May 13, 2023

Hi @j3lev, sorry for the late response, I've been out on vacation the past two weeks.

Thanks so much for your detailed issue! I'll get to this ASAP and update this issue when a fix has been released.

@bgiori
Copy link
Contributor

bgiori commented May 17, 2023

@j3lev Hi I was unable to reproduce the specific error you encountered with a sample app, so I published a beta version with the proposed fix. Before I publish the actual release, can you double check this version works for you without modifying the build.gradle file in the node_modules?

Beta version is 1.1.1-beta.1

@j3lev
Copy link
Author

j3lev commented May 18, 2023

@bgiori Hmm I'm still seeing issues. So you weren't able to reproduce this against a React Native 0.71.7 project? I'm seeing the following error when running a ./gradlew clean against the beta:

* Where:
Build file '/Users/joelevenson/Projects/genoa/genoa/node_modules/@amplitude/experiment-react-native-client/android/build.gradle' line: 59

* What went wrong:
A problem occurred evaluating project ':amplitude_experiment-react-native-client'.
> Could not get unknown property 'kotlin_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

@lernerb
Copy link

lernerb commented May 18, 2023

@bgiori - Try updating the build tools as well (which are required for the RN upgrade) - as well as the gradle wrapper file (e.g. - take a look at the other amplitude RN project @ https://github.com/amplitude/Amplitude-ReactNative/blob/main/example/android/gradle/wrapper/gradle-wrapper.properties#L3)

+ classpath 'com.android.tools.build:gradle:7.3.1'
- classpath 'com.android.tools.build:gradle:3.5.3'

@lernerb
Copy link

lernerb commented May 18, 2023

If you take a look at the Datadog React Native project, they've fixed the issue on there end with these changes.

@bgiori
Copy link
Contributor

bgiori commented May 18, 2023

Hi @j3lev @lernerb,

Thanks for your responses and suggestions, and sorry the previous version was not correct.

I've published a new version, 1.1.1-beta.2, with an updated kotlin version, android target, and com.android.tools.build:gradle package.

Let me know if this works for you.

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

Successfully merging a pull request may close this issue.

3 participants