-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Failed to run android on React Native 0.71 #2418
Comments
I have the start of a fix here #2419 You can use patch-package with iff --git a/node_modules/react-native-code-push/android/codepush.gradle b/node_modules/react-native-code-push/android/codepush.gradle
index 22be273..8eff668 100644
--- a/node_modules/react-native-code-push/android/codepush.gradle
+++ b/node_modules/react-native-code-push/android/codepush.gradle
@@ -25,6 +25,11 @@ gradle.projectsEvaluated {
}
android.applicationVariants.all { variant ->
+ // skip debug build variant
+ if (variant.buildType.name == "debug") {
+ return;
+ }
+
def nodeModulesPath;
if (config.root) {
nodeModulesPath = Paths.get(config.root, "/node_modules");
@@ -48,10 +53,10 @@ gradle.projectsEvaluated {
// Make this task run right after the bundle task
def generateBundledResourcesHash;
- if (variant.hasProperty("bundleJsAndAssets")) {
- def reactBundleTask = variant.bundleJsAndAssets
- jsBundleDir = reactBundleTask.generatedAssetsFolders[0].absolutePath
- resourcesDir = reactBundleTask.generatedResFolders[0].absolutePath
+ def reactBundleTask = tasks.findByName("createBundle${targetName}JsAndAssets")
+ if (reactBundleTask) {
+ jsBundleDir = reactBundleTask.property('jsBundleDir').asFile.get()
+ resourcesDir = reactBundleTask.property('resourcesDir').asFile.get()
jsBundleFile = file("$jsBundleDir/$bundleAssetName")
generateBundledResourcesHash = tasks.create(
@@ -107,7 +112,7 @@ gradle.projectsEvaluated {
generateBundledResourcesHash.dependsOn("recordFilesBeforeBundleCommand${targetName}")
}
- generateBundledResourcesHash.dependsOn("bundle${targetName}JsAndAssets")
+ generateBundledResourcesHash.dependsOn("createBundle${targetName}JsAndAssets")
runBefore("processArmeabi-v7a${targetName}Resources", generateBundledResourcesHash)
runBefore("processX86${targetName}Resources", generateBundledResourcesHash)
runBefore("processUniversal${targetName}Resources", generateBundledResourcesHash) |
same error |
1 similar comment
same error |
The same issue. |
@johnf Thank you for your contribution! Please add the link to this issue in your PR. |
React native now uses react-native-gradle-plugin, which works a bit differently.
having the same issue, your suggested patch works @johnf, thank you for the help. |
React native now uses react-native-gradle-plugin, which works a bit differently.
React native now uses react-native-gradle-plugin, which works a bit differently.
I started a new project, on react-native 0.71.1, but when I ran the patch it threw me an error saying it couldn't be applied
|
The patch needs an update since the last release. Check the PR here #2419 |
Thanks, I applied the newest patch using the PR above, but I'm getting a message with the flavour used during the build time
I applied the patch
|
Can you share the section of your I assume you are using flavours where as I am using variants, might need some changes to support that |
Sure, here you go:
|
If you run the patch in the way of @johnf, it builds normally, but it doesn't actually reflect it. |
@clovisrodriguez I can't reproduce this. Can you send me the output of |
@ko-devHong Do you have adb log output you could share? It is working for me |
Hey John this was the output for the command
|
That doesn't make a lot of sense. Below it's complaining that
But then below it exists
How are you kicking off the build? |
@johnf I'm using |
@clovisrodriguez hmm I can't seem to replicate the issue. Can you share a minimal example repo that exhibits the problem? |
@ys-sherzad I'm using it in dev at the moment, and it's working well. Only reason it's not in production is we haven't done a prod release yet, but that won't hold me back. Make sure you use the PR diff for your patch |
@johnf this is my adb log
|
i'm using
|
I ran into this issue with hermes disabled. After a while, I tested adding It gives a deprecated warning, but it seems to build on Android now with |
same here, but I cannot run hermes on android |
Update: I have forked and merged these changes for the newer RN versions:
|
@rufat diff --git a/node_modules/react-native-code-push-next/android/codepush.gradle b/node_modules/react-native-code-push-next/android/codepush.gradle
- commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir)
+ commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push-next/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir)
- commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir, resourcesMapTempFileName)
+ commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push-next/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir, resourcesMapTempFileName)
- commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js", resourcesDir, resourcesMapTempFileName)
+ commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push-next/scripts/recordFilesBeforeBundleCommand.js", resourcesDir, resourcesMapTempFileName)
|
Thank you for letting me know. I have fixed it. |
React native now uses react-native-gradle-plugin, which works a bit differently.
Is there any fix for this error? Is anyone using 0.71 with hermes enabled and codepush working? |
I'm having that problem too. I am using custom build variant. I'm using RN 0.71.3 and codepush 7.1.0. When I try to build for variant "uatRelease", the android build fails on "mergeUatReleaseResources" because of duplicate assets. Those assets are from @react-navigation/elements (the android back arrow here), but everything is fine when building without codepush and this line in app/build.gradle:
I investigated a bit, and it seems during the build that assets are copied to android/app/build/generated/res/react/uat/release/ and to android/app/build/generated/res/react/uatRelease/ too. Since the same asset is copied in two folders, it causes duplicate assets It happened after applying this patch (inspired by @rufat) : react-native-code-push+7.1.0.patch
I think there is a confusion somewhere between the targetName and targetPath, but I cannot figure out where. It can come from react-native's build.gradle too I am not sure, but since this happens only when I try to add codepush I am posting it here. Anyone has a clue of how to fix this problem ? Maybe another patch of react-native-code-push or react-native directly ? |
@ arnaud9145 @ aquinq. There's an open PR that should fix this issue, so you can either for a new release when this PR gets merged or create your own fork with the fix. |
@ArGeoph Actually I tested the code in the open PR. The code in it generated the patch I sent earlier. It does not fix my problem unfortunately :/ |
@arnaud9145 Are you able to share a minimal reproduction using create-react-app that I could debug? |
@johnf I tried my best to reproduce it here : https://github.com/arnaud9145/DebugCodePushRn071 Tell me if you need anything else :) I included install and launch instructions in the README. Note : I only setup android since my problem is android only. if you need it, I can setup ios too. What should happen : When you launch the app in android studio (work in CLI too with yarn android:uat:release), the build will fail with error "Duplicate resources" in :app:mergeUatreleaseResources step. The asset "node_modules_reactnative_libraries_newappscreen_components_logo.png" is duplicated Why : The asset is copied twice, once in ./android/app/build/generated/res/react/uat/release/drawable-mdpi/node_modules_reactnative_libraries_newappscreen_components_logo.png and another time in ./android/app/build/generated/res/react/uatRelease/drawable-mdpi/node_modules_reactnative_libraries_newappscreen_components_logo.png You can check that after the build, the file should be in both folders. Thanks for your help ! |
@arnaud9145 Thanks that helped. The problem was this line isn't needed https://github.com/arnaud9145/DebugCodePushRn071/blob/main/android/app/build.gradle#L69 I had neglected to update the README, which I've done now with the new instructions cba29a8 |
@johnf That fixed my problem! Thanks a lot 😄 |
For anyone struggling with this and expo 48, here is how I'm doing it: I'm using this patch #2418 (comment) with plugins/expo-codepush/android/codepush.js
plugins/expo-codepush/ios/codepush.js
plugins/expo-codepush/index.js
and then use it like this in App.json/app.config.js:
|
still waiting for the official release |
I've been waiting about 2 months for the official release. So when will the new version be released to fix that? |
React native now uses react-native-gradle-plugin, which works a bit differently.
Hi @luizfelipelaviola, I'm new at this environment, but I think there is a typo in the line above, since it returns an ArrayList, which doesn't have the method get(), rather it has get(int). |
Seems from here that only version 8.x.x supports RN 0.71. run:
to get it Also note that the following line was moved to the end of
|
My react-native version is 0.71.5 and the react-native-code-push version is 8.0.1 (updated today). I had successfully implemented and tested the codepush functionality 2 weeks before. But suddenly today, its broken. I was able to identify the cause of the problem being the URL of the maven repository which was initially located at: https://repo.maven.apache.org/maven2/net/minidev/json-smart/maven-metadata.xml, is inaccessible and not reachable. The package although is still trying to access from here. I was able to figure out the updated URL for the maven-metadata.xml: I tried to make changes to the node_modules but was unsuccessful and thought that changes made to the node_modules would not hold for new app installs. Can someone please resolve this issue? Thanks in advance |
I think maven might have been having issues, their DNS seems to be broken right now |
Thanks for the reply. Then I think all we can do is be patient and wait for it to be fixed |
They have fixed the URL. Will try it and let you know. |
Steps to Reproduce
0.71
following the upgrade helperyarn android
Expected Behavior
App builds and runs under debug mode
Actual Behavior
After upgraded to React Native 0.71, the android build fails with the following message:
Environment
Other Attempts
After removing the following lines from android/build.gradle the build seems to work fine (w/o codepush of course)
The text was updated successfully, but these errors were encountered: