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

React native 0.72.0 #165

Closed
abgaryanharutyun opened this issue Jun 27, 2023 · 7 comments
Closed

React native 0.72.0 #165

abgaryanharutyun opened this issue Jun 27, 2023 · 7 comments

Comments

@abgaryanharutyun
Copy link

After upgrading react native to latest version android build stat to fail,

package.json

    "@amplitude/analytics-react-native": "^1.3.0",
    "react-native": "^0.72.0",

BUILD FAILED in 10s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installAlphaDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':amplitude_analytics-react-native:compileDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain * 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 BUILD FAILED in 10s.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
@Mercy811
Copy link

Mercy811 commented Jul 4, 2023

Hi @abgaryanharutyun, you are using @amplitude/analytics-react-native in the repo. This repo is for @amplitude/react-native.

I cannot reproduce your error. Could you run --stacktrace, --info, --scan and --verbose options to get more info? Thanks.

@abgaryanharutyun
Copy link
Author

@Mercy811 , I will provide additional logs to reproduce the issue easily. However, it is easy to reproduce because it doesn't work with the new React Native version 0.72. Have you tested it with that version? Does it work properly on Android?

@Mercy811
Copy link

Mercy811 commented Jul 5, 2023

Hi @abgaryanharutyun, I got a similar but slightly different one by:

  • npx react-native init AwesomeProject_72 --version 0.72.0
  • yarn android

with environments:

  • "@amplitude/analytics-react-native": "^1.3.1",
  • "@react-native-async-storage/async-storage": "^1.19.0",
  • "react": "18.2.0",
  • "react-native": "0.72.0"
  • gradle plugin version 7.4.0 (you can find these two in Android Studio, File > Project Structure > Project)
  • gradle version 7.5
BUILD FAILED in 4s
error Failed to install the app. Command failed with exit code 1: ./gradlew tasks FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':tasks'.
> Could not create task ':amplitude_analytics-react-native:compileDebugAndroidTestKotlin'. > Cannot use @TaskAction annotation on method AbstractKotlinCompile.execute() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method. * 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 BUILD FAILED in 4s
> Task :gradle-plugin:pluginDescriptors
> Task :gradle-plugin:processResources
> Task :gradle-plugin:compileKotlin
> Task :gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:classes
> Task :gradle-plugin:jar
> Task :gradle-plugin:inspectClassesForKotlinIC
> Task :tasks FAILED Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings
6 actionable tasks: 6 executed.
error Command failed with exit code 1.

Before proceeding, would like to confirm with you we are having the same error and the same environment.

@abgaryanharutyun
Copy link
Author

Hey @Mercy811 ,

I wanted to let you know that I'm experiencing the same issue. It seems to be related to the latest React Native version 0.72. From what I've observed, the problem lies in incompatibility with the new RN version. Surprisingly, iOS is functioning properly, but Android is not.

I would appreciate it if we could address this problem as soon as possible. Can we work together to find a solution or fix?

Looking forward to your response.

@Mercy811
Copy link

Mercy811 commented Jul 6, 2023

Hi @abgaryanharutyun, thanks for your confirmation. It's on the top of my list and will keep you updated. Also really appreciate it if you could let me know if you have any findings.

@abgaryanharutyun
Copy link
Author

abgaryanharutyun commented Jul 6, 2023

Hey @Mercy811 I think this issue not related with amplitude package, I have fixed this issue on my end without amplitude change, so what I did just changed

        compileSdkVersion = 34
        targetSdkVersion = 34

to

compileSdkVersion = 33
targetSdkVersion = 33

@Mercy811
Copy link

Mercy811 commented Jul 6, 2023

Hi @abgaryanharutyun I fixed it in another way, in case you are interested.

Solution

I didn't fixed it by changing compileSdkVersion and targetSdkVersion. But fixed the problem by the adding kotlinVersion to the latest in build.gradle

ext {
        ...
        kotlinVersion = "1.9.0"
        ...
}

Trace down

What I described here amplitude_analytics-react-native:compileDebugAndroidTestKotlin is not the same error as amplitude_analytics-react-native:compileDebugKotlin in the original post.

Step to reproduce

  • Update to the latest Android Studio (from Android Studio Electric Eel to Android Studio Flamingo
  • Change gradle plugin version to 7.4.0 and gradle version to 7.5
  • Run yarn android and get amplitude_analytics-react-native:compileDebugKotlin
    There is an important line in the error message
AwesomeProject_72/node_modules/@amplitude/analytics-react-native/android/src/main/java/com/amplitude/reactnative/AmplitudeReactNativeModule.kt: (26, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

It indicates that this error is caused by the incompatibility of Kotlin. The default Kotlin version compiled to is 1.5.1 however the needed version (probably required by React Native 0.72.0 is at least 1.7.1). So specify the latest Kotlin version in your React Native project should fix the problem.

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

No branches or pull requests

3 participants