Release APK fails immediately on launch (Version 0.54)
See original GitHub issueI have a web view app that is very straightforward. The iOS version is running perfectly. The android version runs perfectly in debug mode using the package server. However, the release version of the apk crashes immediately when launched.
The errors I am getting from logcat are:
03-12 22:12:07.665 16051-16068/? E/AndroidRuntime: FATAL EXCEPTION: Thread-2
Process: com.gtcworx, PID: 16051
java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:216)
at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:33)
at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:234)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1113)
at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:113)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:920)
at java.lang.Thread.run(Thread.java:764)
03-12 22:12:07.789 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.videos-fSpP8T16jLfLPEk3Hl3pmw==/base.apk
03-12 22:12:07.790 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.videos-fSpP8T16jLfLPEk3Hl3pmw==/base.apk
03-12 22:12:07.790 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.videos-fSpP8T16jLfLPEk3Hl3pmw==/base.apk
03-12 22:12:07.794 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.apps.docs.editors.slides-9EEF5YDNu3OKNBNwayfu9g==/base.apk
03-12 22:12:07.794 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.apps.docs.editors.slides-9EEF5YDNu3OKNBNwayfu9g==/base.apk
03-12 22:12:07.794 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.apps.docs.editors.slides-9EEF5YDNu3OKNBNwayfu9g==/base.apk
03-12 22:12:07.795 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.contacts-2KRJls5awi4KQQ6cjkUQQA==/base.apk
03-12 22:12:07.795 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.contacts-2KRJls5awi4KQQ6cjkUQQA==/base.apk
03-12 22:12:07.797 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.dialer-1BN26SkEVNcra4NPGyK-nA==/base.apk
03-12 22:12:07.797 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.dialer-1BN26SkEVNcra4NPGyK-nA==/base.apk
03-12 22:12:07.797 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.google.android.dialer-1BN26SkEVNcra4NPGyK-nA==/base.apk
03-12 22:12:07.798 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.gtcworx-XlyWECmWk-Pjfh6CE3jV4Q==/base.apk
03-12 22:12:07.799 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.gtcworx-XlyWECmWk-Pjfh6CE3jV4Q==/base.apk
03-12 22:12:07.799 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.gtcworx-XlyWECmWk-Pjfh6CE3jV4Q==/base.apk
03-12 22:12:07.799 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.gtcworx-XlyWECmWk-Pjfh6CE3jV4Q==/base.apk
03-12 22:12:07.800 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.gtcworx-XlyWECmWk-Pjfh6CE3jV4Q==/base.apk
03-12 22:12:07.805 2055-2075/? E/ResourcesManager: failed to add asset path /data/app/com.gtcworx-XlyWECmWk-Pjfh6CE3jV4Q==/base.apk
since this does not use the package server, I figured the problem is that the bundle is packaged incorrectly. However, I am not sure that I can do to fix the way the package is bundled.
I did some searches and noticed that this problem is caused the View.propTypes references. I followed the steps to see if there were any such references in my modules and there are not. There are only comments referring to the issue and explaining the patches put into place.
I also found an article that suggested I check the name of the app in the index.js file and compare that with the name in the MainActivity. I checked those and they are identical. I also checked my package.json for the same name.
I have also done several cleans of the project using Gradle.
Thanks for any help that can be provided.
Environment
Environment:
OS: macOS High Sierra 10.13.3
Node: 8.8.1
Yarn: 1.3.2
npm: 5.4.2
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 2.3 AI-162.4069837
Packages: (wanted => installed)
react: ^16.2.0 => 16.2.0
react-native: ^0.54.2 => 0.54.2
Expected Behavior
I expected the app to launch and show the website in the webView.
I am unable to reproduce the error in snack, but here is the link that shows how it should work: https://snack.expo.io/r1JzDYSFG
Actual Behavior
dialog box shows up saying “app has stopped” and ask to open again.
Steps to Reproduce
- Create a web view app
- Build it using the versions of the libs I have above
- Generate a signed release apk
- Install release apk onto device
- Run the app
Issue Analytics
- State:
- Created 6 years ago
- Reactions:15
- Comments:68 (2 by maintainers)
The issue for me was fixed by:
• Within your projects build.gradle change the buildScripts dependencies classpath to ‘com.android.tools.build:gradle:3.1.4’ // I wasn’t able to get v3.2.0 to work, so I had to downgrade to 3.1.4. This might work with lower versions too, but I haven’t tested it. • Placing android.enableAapt2=false within the gradle.properties. • Within the terminal on the Project folder enter cd android && ./gradlew clean assembleRelease • Within the terminal on the Project folder enter react-native run-android --variant=release to verify that the app-release.apk works properly.
I’ve tried with and without ‘org.gradle.configurationOnDemand=false’ with no difference to being able to build. I’m also running react-native: 0.56.1
Hope this helps someone.
Apparently, Gradle 3.2.0 changed the location to which it generates asset bundles. RN expects its JS asset bundle to be in a specific path, which is the path used by Gradle 3.1.4. Because G3.2.0 puts them in a different spot, RN cannot find the JS asset bundle, and thus the files with the Javascript to run. Ergo, the crash in release mode.
In debug mode, the JS files are provided by the Metro daemon, and there is no JS asset bundle to be loaded. That’s why this error only manifests itself in release mode.
This is why lots of people suggest fixes that involve creating the asset bundle manually (via CLI), copying it manually to a specific folder, and then running the apk generator. But, let’s face it, it’s way easier to just downgrade Gradle to a version that works the way RN expects.
Now, why the RN devs didn’t update the native source code to get the bundle from its new location, that is a mystery that I haven’t figured out.