React-native-code-push: Unable to load script from assets 'index.android.bundle'.

Created on 17 Dec 2018  Â·  9Comments  Â·  Source: microsoft/react-native-code-push

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
android waiting-for-clarification

Most helpful comment

@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!

All 9 comments

fixed by this

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

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!

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

@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!

it work, thanks

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!

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",

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

osdnk picture osdnk  Â·  3Comments

Fuhrmann picture Fuhrmann  Â·  3Comments

vira-khdr picture vira-khdr  Â·  3Comments

Phredward picture Phredward  Â·  3Comments

panarasi picture panarasi  Â·  4Comments