Closed nirikshan closed 1 year ago
Same issue here.. always with 0.70.6...
I have same issue, even 0.70.5 and 0.70.6. Anyone can help? My company is waiting the build. thanks so much
same issue here as well, RN v.0.70.6
I have the same issue after upgrade RN from 0.70.3 to 0.70.6
I have tried creating a fully new project on react native 0.70.6 and generated a signed app which worked fine but didn't work with dependencies
@nirikshan you should try to understand which dependency is creating this issue. If a blank project is working fine, there is not much we can do at this stage.
To all the others commenting "same issue": please provide a reproducer or refrain from hijacking other issue reports.
I think that dependencies are of no greater importance here. The problem it is in the gradle version:
Downgrade gradle helps me in my case.
In: android/gradle/wrapper/gradle-wrapper.properties
i changed version from 7.5.1
to 7.3.3.
In: android/build.gradle i changed gradle
from : classpath("com.android.tools.build:gradle:7.2.1")
to classpath("com.android.tools.build:gradle:7.1.1")
I think that dependencies are of no greater importance here. The problem it is in the gradle version:
They are instead.
If a newly created project on 0.70.6
works correclty, then the issue is in either a user configuration (i.e. changing Gradle/AGP version as you're suggesting) or in a 3rd party dependency.
Hello everyone, I had the same problem as yours when generating my release version, @cortinico is correct, it must be some incompatibility between libraries, in my case, there was the following in the project: react-native-gradle-plugin, I just removed it from package.json and everything worked fine.
@SusulAdam's comment has helped me. I followed what he told me and also downgraded react-native-gradle-plugin at package.json to 0.70.3 . Currently I have react-native 0.70.6 and It's working perfectly.
I followed what he told me and also downgraded react-native-gradle-plugin at package.json to 0.70.3
Just a heads up that downgrading react-native-gradle-plugin
is not the right solution.
It's a workaround for an underlying issue. You will have problems when you try to upgrade to .71 once it's out if you keep on with this workaround.
Also you should not have react-native-gradle-plugin
in your package.json at all as that dependency is provided by react-native
.
Well, when I ran it to generate the assemble I received an error coming from a library react-native-device-country,
because it had incompatible versions, when I installed react-native-gradle-plugin
in the package.json the error disappeared, but this error message Unable to load script...
started to appear, in my case I solved it by updating the
DeviceCountry_compileSdkVersio=31
DeviceCountry_targetSdkVersion=31
After that, I removed react-native-gradle-plugin
, and I didn't get any more problems.
So my tip to try to identify which lib is in conflict is to remove react-native-gradle-plugin
, and run ./gradlew assembleRelease
And see if there are any problems.
After that, try to solve it together with the library maintainers, with PRs etc...
Just wanted to add another data point. I recently made the upgrade to React Native 0.70.7 (previously from 0.69.x and 0.67.x). I was able to build and deploy releases locally, but the app would crash when installing internal builds from the Google Play store. I was seeing errors like:
java.lang.RuntimeException:` Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release
As mentioned above, the solution was to remove react-native-gradle-plugin
and now release builds are no longer crashing on app launch! It looks like that library was an artifact from my RN 0.69 upgrade migration. Same with react-native-codegen
.
Here's my solution, may or may not work for you:
index.android.bundle
was making it into the app bundle but incorrectly nested in a directory: assets/mergeStagingReleaseAssets/index.android.bundle
. I added flavors to my app for staging and production environments and upgraded AGP for compatibility with another dependency (firebase I think).app/build.gradle
above apply from: "../../node_modules/react-native/react.gradle"
)
project.ext.react = [
// ...
// where to put the JS bundle asset in release mode
// react.gradle puts this in a merged${flavor}Assets directory by default which RN cannot find
jsBundleDirStagingRelease: "$buildDir/intermediates/assets/stagingRelease",
jsBundleDirProductionRelease: "$buildDir/intermediates/assets/productionRelease",
]
it seems the default behavior in react.gradle was putting the bundle in a directory which got moved into the app bundle in a way that react native could not find.
if you analyze your app bundle / apk and find a similar problem (index.android.bundle) is in a subdirectory below assets
, then my solution will hopefully help you!
Here's my solution, may or may not work for you:
- My
index.android.bundle
was making it into the app bundle but incorrectly nested in a directory:assets/mergeStagingReleaseAssets/index.android.bundle
. I added flavors to my app for staging and production environments and upgraded AGP for compatibility with another dependency (firebase I think).- I was able to correct this behavior by explicitly setting (in
app/build.gradle
aboveapply from: "../../node_modules/react-native/react.gradle"
)project.ext.react = [ // ... // where to put the JS bundle asset in release mode // react.gradle puts this in a merged${flavor}Assets directory by default which RN cannot find jsBundleDirStagingRelease: "$buildDir/intermediates/assets/stagingRelease", jsBundleDirProductionRelease: "$buildDir/intermediates/assets/productionRelease", ]
it seems the default behavior in react.gradle was putting the bundle in a directory which got moved into the app bundle in a way that react native could not find.
if you analyze your app bundle / apk and find a similar problem (index.android.bundle) is in a subdirectory below
assets
, then my solution will hopefully help you!
I found this after a long and endless search, which was exactly what I needed. Thank you sir! I believe this fix would is the correct one if you upgraded AGP but not the react native version, which is when the mismatch happens and this behaviour occurs.
Here's my solution, may or may not work for you:
- My
index.android.bundle
was making it into the app bundle but incorrectly nested in a directory:assets/mergeStagingReleaseAssets/index.android.bundle
. I added flavors to my app for staging and production environments and upgraded AGP for compatibility with another dependency (firebase I think).- I was able to correct this behavior by explicitly setting (in
app/build.gradle
aboveapply from: "../../node_modules/react-native/react.gradle"
)project.ext.react = [ // ... // where to put the JS bundle asset in release mode // react.gradle puts this in a merged${flavor}Assets directory by default which RN cannot find jsBundleDirStagingRelease: "$buildDir/intermediates/assets/stagingRelease", jsBundleDirProductionRelease: "$buildDir/intermediates/assets/productionRelease", ]
it seems the default behavior in react.gradle was putting the bundle in a directory which got moved into the app bundle in a way that react native could not find. if you analyze your app bundle / apk and find a similar problem (index.android.bundle) is in a subdirectory below
assets
, then my solution will hopefully help you!I found this after a long and endless search, which was exactly what I needed. Thank you sir! I believe this fix would is the correct one if you upgraded AGP but not the react native version, which is when the mismatch happens and this behaviour occurs.
It works in RN67.4 and SDK34.
New Version
0.70.6
Old Version
0.66.0
Build Target(s)
Android
Output of
react-native info
System: OS: macOS 13.0.1 CPU: (8) arm64 Apple M1 Memory: 41.77 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.7.0 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.1.1 - /usr/local/bin/npm Watchman: 2022.09.05.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 23, 27, 28, 29, 30, 31, 33 Build Tools: 28.0.3, 29.0.0, 29.0.1, 29.0.2, 30.0.2, 30.0.3, 31.0.0 System Images: android-29 | Google APIs ARM 64 v8a, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-30 | Google APIs ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-31 | Google APIs ARM 64 v8a, android-31 | Google Play ARM 64 v8a, android-33 | Google Play ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7583922 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 18.0.1.1 - /opt/homebrew/opt/openjdk/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.6 => 0.70.6 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Issue and Reproduction Steps
Currently, I have completed updating my project to React-Native 0.70.6 (The Latest). Everything is working as expected during development (npm run android) and Apk builds process also generates APK without any error. But when I run my Final APK app suddenly crashes without any error. To detect the reason for crash I have used several debugging tools. Which gives me the error as shown below
I have searched everywhere about this problem on the web. I read several posts and got several suggestions that I have implemented in my files.
My android/build.gradle file :
Few configurations of android/app/build.gradle
Result of java --version
I have tried creating a fully new project on react native 0.70.6 and generated a signed app which worked fine but didn't work with dependencies. I found using dependencies creates this problem
My package.json :
Please help me