Hi,
I have an issue when launching an Android app with a release build (or a non-debug build) when using gradle:3.4.0 plugin and gradle-5.1.1 wrapper
The app crash directly after launch and I can see the following error in the logcat tab of Android Studio :
2019-05-15 11:16:39.412 31945-31961/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.testproject, PID: 31945
java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:218)
at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:31)
at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:247)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1152)
at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943)
at java.lang.Thread.run(Thread.java:764)
The issue only happen with this version of Gradle plugin/wrapper and in release build.
If you do a debug build with the metro bundler started on your computer, it's working fine.
With the previous version (gradle plugin 3.1.1, gradle wrapper 4.10.2) it's working fine (debug and release).
I tested with
implementation "com.facebook.react:react-native:+"
and
implementation ("com.facebook.react:react-native:0.59.8"){force=true}
and it doesn't change anything
The issue happens on emulator and real devices.
React Native version: 0.59.8 (but also with previous version (tested with 0.58.6))
Gradle plugin version: 3.4.0
Gradle wrapper version: 5.1.1
If you need something else or more tests, just let me know
Thanks in advance for your support
Hello there 馃憢
I think that the core of the issue lays here
dump gradle plugin from 3.3.1 to 3.4.0 and gradle wrapper from 4.10.2 to 5.1.1
I am pretty sure that react native can't use Gradle 5 for now - have you seen somewhere in the changelog mentioning that is supported (I may be wrong)?
Do you have any precise reasons for needing to use Gradle 5?
Also, it seems that it's probably the same issue described here: https://github.com/facebook/react-native/issues/24854 so it seems to be related also to 3.4.0?
I'm closing this in favour of that other issue, but I'll ping internally if we are aware of these incompatibilities
Do you have any precise reasons for needing to use Gradle 5?
It's the latest available version and Android Studio ask me to update my project so I tried ;-)
But indeed I haven't seen that we can use this version of Gradle yet.
Thanks for the reply
Seen same issue with RN 0.59.2. Android Studio upgraded gradle to version 5:
classpath 'com.android.tools.build:gradle:3.3.2' (/android/build.gradle)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip (gradle-wrapper.properties)
to
classpath 'com.android.tools.build:gradle:3.4.0'
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Reverting these changes fixed the issue for me! Thanks for the help!
Most helpful comment
Seen same issue with RN 0.59.2. Android Studio upgraded gradle to version 5:
classpath 'com.android.tools.build:gradle:3.3.2'(/android/build.gradle)distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip(gradle-wrapper.properties)to
classpath 'com.android.tools.build:gradle:3.4.0'distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zipReverting these changes fixed the issue for me! Thanks for the help!