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

[HAS WORKAROUND] Android build fails since 0.71.0-rc.0 tag added #35204

Closed
markholland opened this issue Nov 4, 2022 · 79 comments
Closed

[HAS WORKAROUND] Android build fails since 0.71.0-rc.0 tag added #35204

markholland opened this issue Nov 4, 2022 · 79 comments
Labels
DX Issues concerning how the developer experience can be improved. Impact: Errors During Build Platform: Android Android applications. Resolution: Answered When the issue is resolved with a simple answer Tool: Gradle

Comments

@markholland
Copy link

markholland commented Nov 4, 2022

WORKAROUND

Issue #35210 now has the best description and current best-known fix for the issue

we are working hard to keep that issue up to date as we learn new things

go to the issue and get the workaround: #35210

Original issue report follows:


Description

Builds started failing couple hours ago.

* What went wrong:
Execution failed for task ':app:mergeReleaseNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
   > 2 files found with path 'lib/arm64-v8a/libfbjni.so' from inputs:
      - [redacted]/.gradle/caches/transforms-3/2952ab139faaa4b08a71276c5fc46221/transformed/jetified-react-native-0.71.0-rc.0-release/jni/arm64-v8a/libfbjni.so
      - [redacted]/.gradle/caches/transforms-3/d1c59095249a1169bea435013b70e0a9/transformed/jetified-fbjni-0.3.0/jni/arm64-v8a/libfbjni.so
     If you are using jniLibs and CMake IMPORTED targets, see
     https://developer.android.com/r/tools/jniLibs-vs-imported-targets

Version

0.68.3

Output of npx react-native info

info Fetching system and libraries information...
System:
OS: macOS 13.0
CPU: (20) arm64 Apple M1 Ultra
Memory: 2.37 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.1 - ~/Library/Caches/fnm_multishells/89099_1667585876627/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.11.0 - ~/Library/Caches/fnm_multishells/89099_1667585876627/bin/npm
Watchman: 2022.10.31.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9014738
Xcode: 14.1/14B47b - /usr/bin/xcodebuild
Languages:
Java: 11.0.16.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.68.3 => 0.68.3
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

  • npx react-native run-android

Snack, code example, screenshot, or link to a repository

N/A

@markholland

This comment was marked as outdated.

@afturner

This comment was marked as duplicate.

@bernygarza-bh

This comment was marked as duplicate.

@leonardoquevedox

This comment was marked as duplicate.

@prolok

This comment was marked as duplicate.

@Gabarros

This comment was marked as duplicate.

@saransh-malik

This comment was marked as duplicate.

@vladyslavNiemtsev

This comment was marked as duplicate.

@BlinkVonDoom

This comment was marked as duplicate.

@mikehardy

This comment was marked as outdated.

@prolok

This comment was marked as outdated.

@mikehardy

This comment was marked as outdated.

@bkasten-rbi
Copy link

@mikehardy I appreciate the advice. I'm just a little concerned that a rc release was able to suddenly break several projects CI builds. Is it truly the right solution that consumers need to fix this locally?

@afturner

This comment was marked as outdated.

@prerakd

This comment was marked as resolved.

@mikehardy
Copy link
Contributor

mikehardy commented Nov 4, 2022

@bkasten-rbi absolutely not the right solution solution we hope for, that back-versions need to fix this locally, but I am a deeply pragmatic person, and it is Friday, already after business hours in Europe (where many of the release folks live) so I'm casting about for any workaround as this is clearly a Very Big Deal.

I'm not even sure what the root cause is yet, just trying to mention the gradle adjustements I'm aware of that might unblock people if they are stuck

@jaredh
Copy link

jaredh commented Nov 4, 2022

This is happening because all the templates reference the React Native dependency by range, like implementation 'com.facebook.react:react-native:+'. Usually this dependency gets resolved from the local Maven repo in ./node_modules/react-native/android but since it has been published to Maven Central it's now grabbing the very latest RC.

You can resolve this problem by forcing the React Native dependency to the version you expect with something like this implementation 'com.facebook.react:react-native:0.68.2!!' in your app's Gradle file. The !! is shorthand for restricting Gradle from upgrading if your project or its transitive dependencies depend on a newer version.

AFAIK Maven Central is immutable and the published dependency can't removed so this might be the only solution.

@mikehardy

This comment was marked as outdated.

@Grohden

This comment was marked as outdated.

@mikehardy
Copy link
Contributor

mikehardy commented Nov 4, 2022

I think this has to do with the publish of the RC to maven central - perhaps that is the root cause, perhaps that is something that does not normally happen such that the + range works normally but it is biting everyone now that a public repository has a newer dep.

[edit: confirmed it was published to maven central, that is triggering this: https://repo1.maven.org/maven2/com/facebook/react/react-native/]

I want to amplify the comment from @jaredh is this could use some success reports if others try it:

You can resolve this problem by forcing the React Native dependency to the version you expect with something like this implementation 'com.facebook.react:react-native:0.68.2!!' in your app's Gradle file. The !! is shorthand for restricting Gradle from upgrading if transitive dependencies depend on a newer version.

@afturner
Copy link

afturner commented Nov 4, 2022

I can confirm that setting the following works:

configurations.all {
  resolutionStrategy {
    force 'com.facebook.react:react-native:0.68.2'
  }
}

I'm doing some more testing but would appreciate any other confirmations. Thanks for the information @jaredh

ref: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

@mishkeTz

This comment was marked as resolved.

@mikehardy
Copy link
Contributor

mikehardy commented Nov 4, 2022

@afturner based on my lookup just now to cross-check that the artifact really does exist on maven central this appears to be the root cause:

  • typical react-native build.gradle includes + range
  • typical react-native publish does not publish to maven central
  • this RC was published to maven central and has a higher version than local
  • typical react-native build.gradle thus pulls the new (unwanted) RC version from maven central
  • build fails

Thus I think either workaround - pinning the version in the dep or setting it via resolution strategy are fully functional

@bkasten-rbi
Copy link

@mikehardy thank you!

in addition to that, do we think its possible to remove it from maven until the versioning issue is sorted out?

@mikehardy
Copy link
Contributor

@bkasten-rbi maven is immutable. The damage is done, there is no undoing it 😢 (link from jaredh https://central.sonatype.org/faq/can-i-change-a-component/#question)

@mikehardy mikehardy changed the title Android build fails since 0.71.0-rc.0 tag added [HAS WORKAROUND] Android build fails since 0.71.0-rc.0 tag added Nov 4, 2022
@Pakvothe
Copy link

Pakvothe commented Nov 6, 2022

Hi, after applying the fix the build in eas works correctly, but when running the application in production in android it crashes at startup. Does it happen to anyone else? any solution?

@Thanhal-P-A
Copy link

Add this fix to your android -> build.gradle file as follows:

buildscript {
    // ...
}


allprojects {
    repositories {
       exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }
        // ...
    }
}

What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules

Ref: Fix and updates on Android build failures happening since Nov 4th 2022 #35210

@facebook facebook deleted a comment from satyabrata45 Nov 6, 2022
@facebook facebook deleted a comment from Arnav7501 Nov 6, 2022
@facebook facebook deleted a comment from mardikarifqi Nov 6, 2022
@facebook facebook deleted a comment from skjangid Nov 6, 2022
@facebook facebook deleted a comment from eramudeep Nov 6, 2022
@facebook facebook deleted a comment from skantus Nov 6, 2022
@facebook facebook deleted a comment from Rajdeep4536 Nov 6, 2022
@facebook facebook deleted a comment from Libero793 Nov 6, 2022
@facebook facebook deleted a comment from azhararmar Nov 6, 2022
@facebook facebook deleted a comment from thanksyouall Nov 6, 2022
@facebook facebook deleted a comment from melek-hedhili Nov 6, 2022
@facebook facebook deleted a comment from faustoct1 Nov 6, 2022
@facebook facebook deleted a comment from mardikarifqi Nov 6, 2022
@facebook facebook deleted a comment from bozaigao Nov 6, 2022
@anveshbabu

This comment was marked as resolved.

@mariaeduardaes
Copy link

I'm trying to apply the fix but i'm getting this error:
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find any matches for com.facebook.react:react-native:+ as no versions of com.facebook.react:react-native are available.
Required by:
project :app
project :app > project :react-native-community_slider

@mikehardy
Copy link
Contributor

@anveshbabu that is a more brittle version of the recommendation for people on old react-native as it hardcodes the react-native version, we do not recommend it.
@mariaeduardaes something about the application of the workaround is incorrect but you have not provided enough details to help (specifically, no version information of anything is included, nor do you mention which workaround you are attempting https://stackoverflow.com/help/how-to-ask) - I suggest if no versions are available, then the workaround may not be in the correct place in your build.gradle

@mikehardy
Copy link
Contributor

THE CURRENT BEST FIX IS ON #35210

There is information there that explains what you need to do, based on what react-native version you are using.

Go to that issue and read it, please.

@mariaeduardaes

This comment was marked as resolved.

@mikehardy

This comment was marked as resolved.

@mariaeduardaes

This comment was marked as resolved.

@mikehardy

This comment was marked as resolved.

@mariaeduardaes

This comment was marked as resolved.

@mikehardy

This comment was marked as resolved.

@mikehardy
Copy link
Contributor

THE CURRENT BEST FIX IS ON #35210

There is information there that explains what you need to do, based on what react-native version you are using.

We are working hard to keep that issue up to date as we learn new things

Go to that issue and read it, please

@facebook facebook locked and limited conversation to collaborators Nov 6, 2022
@kelset
Copy link
Collaborator

kelset commented Nov 10, 2022

The issue has now been fully addressed, please refer to #35210 (comment) for details

@kelset kelset closed this as completed Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DX Issues concerning how the developer experience can be improved. Impact: Errors During Build Platform: Android Android applications. Resolution: Answered When the issue is resolved with a simple answer Tool: Gradle
Projects
None yet
Development

Successfully merging a pull request may close this issue.