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

Unable to load script from assets 'index.android.bundle'. #1474

Closed
LzxHahaha opened this issue Dec 17, 2018 · 9 comments
Closed

Unable to load script from assets 'index.android.bundle'. #1474

LzxHahaha opened this issue Dec 17, 2018 · 9 comments

Comments

@LzxHahaha
Copy link

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Steps to Reproduce

  1. Config code push just like the document said
  2. Generate and install a release apk
  3. Try to run and then will crash

Expected Behavior

No crash

Actual Behavior

adb logcat:

12-17 14:18:30.851 12660 12676 D ReactNative: Initializing React Xplat Bridge.
12-17 14:18:30.851 12660 12676 D ReactNative: Initializing React Xplat Bridge before initializeBridge
12-17 14:18:30.861 12660 12676 D ReactNative: Initializing React Xplat Bridge after initializeBridge
12-17 14:18:30.861 12660 12676 D ReactNative: CatalystInstanceImpl.runJSBundle()
12-17 14:18:30.871 12660 12676 E AndroidRuntime: FATAL EXCEPTION: Thread-19940
12-17 14:18:30.871 12660 12676 E AndroidRuntime: Process: com.xxxapp, PID: 12660
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 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.
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 	at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 	at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:216)
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 	at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:32)
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 	at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:243)
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1114)
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:116)
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:913)
12-17 14:18:30.871 12660 12676 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:818)

I try to unarchiver the apk, there is nothing in asset directory, so I tried to manually generate a bundle with

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest res

and generate a new apk, this one work just fine.

It any way to automatic generate index.android.bundle ?

Environment

  • react-native-code-push version: 5.4.2
  • react-native version: 0.57.4
  • iOS/Android/Windows version: Android 6.0.1
  • Does this reproduce on a debug build or release build? Release only
  • Does this reproduce on a simulator, or only on a physical device? Physical device
@LzxHahaha
Copy link
Author

fixed by this

@LzxHahaha
Copy link
Author

Not working for staging

project.ext.react = [
    entryFile: "index.js",
    jsBundleDirDebug: "$buildDir/intermediates/merged_assets/debug/mergeDebugAssets/out",
    jsBundleDirStaging: "$buildDir/intermediates/merged_assets/staging/mergeStagingAssets/out",
    jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/mergeReleaseAssets/out"
]

...

staging {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
        matchingFallbacks = ['debug', 'release']
}

run gradlew assembleStaging and no bundle has been generated

@LzxHahaha LzxHahaha reopened this Dec 20, 2018
@yuri-kulikov
Copy link
Contributor

Hi @LzxHahaha,
Thanks for reporting!

Could you please clarify which version of gradle you are using?
And if you could provide us with a simple reproducible demo it would be very helpful!

@LzxHahaha
Copy link
Author

Hi @LzxHahaha,
Thanks for reporting!

Could you please clarify which version of gradle you are using?
And if you could provide us with a simple reproducible demo it would be very helpful!

gradle 3.2.1
demo

there are the generated files after run ./gradlew assembleStaging and ./gradlew assembleRelease

@yuri-kulikov
Copy link
Contributor

yuri-kulikov commented Dec 21, 2018

@LzxHahaha thank you for that demo!

I reproduced the issue and found how to fix it.
You don't need to use this:

project.ext.react = [
    entryFile: "index.js",
    jsBundleDirDebug: "$buildDir/intermediates/merged_assets/debug/mergeDebugAssets/out",
    jsBundleDirStaging: "$buildDir/intermediates/merged_assets/staging/mergeStagingAssets/out",
    jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/mergeReleaseAssets/out"
]

It's a workaround for another issue (react-native < 0.57.2 + gradle plugin >= 3.2)

You need this (I've found a good example here):

project.ext.react = [
    entryFile: "index.js",
    bundleInStaging: true,
    devDisabledInStaging: true,
]

Please let me know if it helps you!

@LzxHahaha
Copy link
Author

it work, thanks

@yuri-kulikov
Copy link
Contributor

Great, glad to help!

I'll close the issue for now, but if you have any questions, feel free to reopen it.
Thanks for using CodePush!

@hardikmobileappsdev
Copy link

i'm getting same issue in signing release apk

AndroidRuntime: FATAL EXCEPTION: Thread-6
   Process: com.app.meatex, PID: 4542
   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:31)
       at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:234)
       at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1114)
       at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:113)
       at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:911)
       at java.lang.Thread.run(Thread.java:764)

"react-native": "0.55.4",

@OzzieOrca
Copy link

Removing

    jsBundleDirDebug: "$buildDir/intermediates/merged_assets/debug/mergeDebugAssets/out",
    jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/mergeReleaseAssets/out"

fixed it for me. Looks like I added them to fix something with react-native-fabric which we've since removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants