chenop
chenop

Reputation: 5133

App Center - Android release crash on startup

Issue happens while deploying a React-Native app via App Center - no crash when doing gradlew assembleRelease locally.
IOS build, deploy and running and build successfully.
In Android - Build passed successfully but when Im installing the app it crashes on startup.

When I check logcat I see the below error - Its seems like the version is a debug version (metro mentioned) but Im not sure.

What could be the issue?

2021-11-09 08:54:36.227 21255-21326/? E/unknown:ReactNative: ReactInstanceManager.createReactContext: mJSIModulePackage null 2021-11-09 08:54:36.227 898-898/? E/libc: Access denied finding property "ro.hardware.fp.fod" 2021-11-09 08:54:36.228 898-898/? E/libc: Access denied finding property "ro.hardware.fp.sideCap" 2021-11-09 08:54:36.229 21255-21326/? E/unknown:DisabledDevSupportManager: Caught exception 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:234) at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29) at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:258) at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1293) at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:131) at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1016) at java.lang.Thread.run(Thread.java:919)

--------- beginning of crash 2021-11-09 08:54:36.229 21255-21326/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.toluna.webservice, PID: 21255
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:234) at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29) at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:258) at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1293) at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:131) at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1016) at java.lang.Thread.run(Thread.java:919)

Upvotes: 3

Views: 2977

Answers (1)

chenop
chenop

Reputation: 5133

Finally solved it. It seems this is a react-native 0.63.3 issue and not an App Center issue.

When doing the follow:

gradlew clean
gradlew assembleRelease // or other variant

This issue is that Build passed successfully but the index.android.bundle file is not created inside the apk.

to check that you can do:

1. unzip [APK_FILE] -d [directory] 
2. Go to assets directory and look for index.android.bundle file.

Only after running again:

gradlew assembleRelease // or other variant

we get the index.android.bundle file inside the apk

Its seems there is a tasks order issue - was solved with this thread

by adding to the app/build.gradle:

// Fix for bundle not getting included in APK or AAB with android gradle plugin 4+
// Seems like there's a React-Native bug - task ordering issue and the assets get computed before the bundle is copied
// This forces the copy task to run before merge resources
// This should be fixed and removed starting with RN 0.63.4.
// Relevant thread: https://github.com/facebook/react-native/issues/29398#issuecomment-724350920
project.afterEvaluate {
  def isAndroidLibrary = plugins.hasPlugin("com.android.library")
  def variants = isAndroidLibrary ? android.libraryVariants : android.applicationVariants
  variants.all { def variant ->
    def targetName = variant.name.capitalize()
    def mergeResourcesTask = tasks.findByName("merge${targetName}Resources")
    def assetsCopyTask = tasks.findByName("copy${targetName}BundledJs")
    mergeResourcesTask.dependsOn(assetsCopyTask)
    logger.warn("Making task ${mergeResourcesTask} depend on ${assetsCopyTask}")
  }
}

Upvotes: 3

Related Questions