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

fix(core): fix build error with react native 73 & AGP 8 #593

Closed
wants to merge 1 commit into from

Conversation

rvasseur31
Copy link

What does this PR do?

This PR aims to fix a build error with React Native 73 (or Expo 50) & AGP 8. Since React Native 73, Java 17 is required.

The fix comes from an expo native module patch, that you can find here : https://gist.github.com/brentvatne/61cd1a938fb4ba8869bc490647aa52e8/revisions

Motivation

We want to build properly our app with the last React Native version

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@rvasseur31 rvasseur31 requested a review from a team as a code owner January 24, 2024 16:10
@louiszawadzki
Copy link
Contributor

Hi @rvasseur31, thanks a lot for taking the time to troubleshoot your issue and open this PR!

For reference, could you describe the error message you did get and under which conditions?

If you can share a repo reproducing the bug or steps to create one that would also greatly help us in reviewing this :)

Thanks a lot!

@rvasseur31
Copy link
Author

Hi @louiszawadzki !

Here is the error :

> Task :datadog_mobile-react-native:compileDebugKotlin 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.

For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
485 actionable tasks: 3 executed, 482 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':datadog_mobile-react-native:compileDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 17) 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 28s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 -PreactNativeDebugArchitectures=arm64-v8a -PreactNativeArchitectures=arm64-v8a FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':datadog_mobile-react-native:compileDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 17) 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 28s.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.

I don't have the time to share a simple repo today, I will try to do it before the end of the week.

@rvasseur31
Copy link
Author

Here is the step to reproduce the error :

  • Create a new React Native project with the latest version npx react-native@latest init DatadogAndroidBuildError
  • Install the latest Datadog version : npm i @datadog/mobile-react-native@latest
  • Run the Android project : npm run android

Here is the project repo : https://github.com/rvasseur31/datadog-android-build-error

@louiszawadzki
Copy link
Contributor

Hi @rvasseur31, thanks a lot for sharing this so quickly!

We are able to reproduce the issue and we had other reports of it today.
We also need to make the change on other packages and it seems that parts of our CI does not run on external contributors PRs.
As this is a quite urgent fix I've opened another PR to take care of all this: #594

Once it is merged I'll close this PR, I hope you understand that this is the fastest way for us to release this fix.

We'll also dig more into why this issue happens and raise it to RN maintainers, it seems to have been added in the last 0.73 release candidate and wasn't mentioned on the migration guide for libraries so plenty of other libs might be impacted.

@rvasseur31
Copy link
Author

No worries and thanks for the explanation!

We're using patch-package while waiting for a new version

@louiszawadzki
Copy link
Contributor

Hi @rvasseur31, we've released @datadog/mobile-react-native version 2.0.4 that should fix your issue.
Let us know if you encounter any other 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

Successfully merging this pull request may close these issues.

2 participants