gpt4 book ai didi

android - App Center - Android 版本在启动时崩溃

转载 作者:行者123 更新时间:2023-12-04 23:57:23 82 4
gpt4 key购买 nike

通过 App Center 部署 React-Native 应用时出现问题 - 在本地执行 gradlew assembleRelease 时没有崩溃。
IOS build, deploy and running 构建成功。
在 Android 中 - 构建成功通过,但当我安装应用程序时它在启动时崩溃。

当我检查 logcat 时,我看到以下错误 - 该版本似乎是调试版本(提到了 metro),但我不确定。

可能是什么问题?

2021-11-09 08:54:36.227 21255-21326/? E/unknown:ReactNative:ReactInstanceManager.createReactContext: mJSIModulePackage null2021-11-09 08:54:36.227 898-898/? E/libc: Access denied findingproperty "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 exceptionjava.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') orthat your bundle 'index.android.bundle' is packaged correctly forrelease.at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(NativeMethod)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 forrelease.at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(NativeMethod)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)

最佳答案

终于解决了。这似乎是一个 react-native 0.63.3 问题,而不是 App Center 问题。

执行以下操作时:

gradlew clean
gradlew assembleRelease // or other variant

这个问题是Build成功了,但是apk里面没有创建index.android.bundle文件。

检查您是否可以:

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

仅在再次运行之后:

gradlew assembleRelease // or other variant

我们得到apk里面的index.android.bundle文件

似乎存在任务顺序问题 - 已通过此 thread 解决

通过添加到 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}")
}
}

关于android - App Center - Android 版本在启动时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69894091/

82 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com