React Native 崩溃 - 灰屏 - 仅限 App Center 构建 - com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(本机方法)

React Native Crash - Grey Screen - App Center build only - com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)

在几乎没有配置更改的发布版本中出现灰屏死机 index.android.bundle。我在线程中包含了 Android 日志中的一个块,在我从 App Center 下载构建后发现了两次崩溃 (Crashlytics + Native)。

注意:App Center 抱怨 Gradle 4.1.0+ 不受支持,要使用更早的版本

无法加载脚本。确保您 运行 正在使用 Metro 服务器 (运行 'react-native start') 或者您的包 'index.android.bundle' 已正确打包以供发布。

主动崩溃

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.
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)

现在,我能想到的唯一变化是更新 Crashlytics for React Native,或 @react-native-firebase/crashlytics。但是在更改后它在初始构建中再次构建良好,然后在 JS 中进行一些小修复后,构建在 Android 的 App Center 中停止工作。这种配置已经存在了一段时间。我不知道为什么会不断出现这种情况。

图片:

日志:

 HostConnection: HostConnection::get() New Host Connection established 0xf412d5e0, tid 26466
01-13 17:57:52.026 26389 26472 E unknown:ReactNative: ReactInstanceManager.createReactContext: mJSIModulePackage null
01-13 17:57:52.026 26389 26478 E ReactNativeJNI: logMarker CREATE_REACT_CONTEXT_END
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics: Settings request failed.
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics: java.net.ConnectException: Failed to connect to firebase-settings.crashlytics.com/0.0.0.0:443
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:265)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:183)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:169)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.RealCall.execute(RealCall.java:81)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at com.google.firebase.crashlytics.internal.network.HttpRequest.execute(HttpRequest.java:129)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at com.google.firebase.crashlytics.internal.settings.network.DefaultSettingsSpiCall.invoke(DefaultSettingsSpiCall.java:86)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at com.google.firebase.crashlytics.internal.settings.SettingsController.then(SettingsController.java:200)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at com.google.firebase.crashlytics.internal.settings.SettingsController.then(SettingsController.java:193)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at com.google.android.gms.tasks.zzp.run(Unknown Source:2)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at com.google.firebase.crashlytics.internal.common.ExecutorUtils.onRun(ExecutorUtils.java:64)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at com.google.firebase.crashlytics.internal.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:27)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.lang.Thread.run(Thread.java:923)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics: Caused by: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 443) from /127.0.0.1 (port 39744) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at libcore.io.IoBridge.isConnected(IoBridge.java:287)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at libcore.io.IoBridge.connectErrno(IoBridge.java:192)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at libcore.io.IoBridge.connect(IoBridge.java:134)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:228)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at java.net.Socket.connect(Socket.java:621)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.platform.AndroidPlatform.connectSocket(AndroidPlatform.java:71)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:263)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   ... 28 more
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics: Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   at libcore.io.IoBridge.isConnected(IoBridge.java:274)
01-13 17:57:52.063 26389 26424 E FirebaseCrashlytics:   ... 38 more
01-13 17:57:52.086 26389 26466 D HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0 
01-13 17:57:52.090   178   178 I hwservicemanager: getTransport: Cannot find entry android.hardware.configstore@1.0::ISurfaceFlingerConfigs/default in either framework or device manifest.
01-13 17:57:52.091 26389 26466 W OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
01-13 17:57:52.093 26389 26466 D EGL_emulation: eglCreateContext: 0xf412d650: maj 3 min 0 rcv 3
01-13 17:57:52.107 26389 26466 D EGL_emulation: eglMakeCurrent: 0xf412d650: ver 3 0 (tinfo 0xf447b3d0) (first time)
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager: Caught exception
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager: 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.
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager:     at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager:     at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:234)
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager:     at com.facebook.react.bridge.JSBundleLoader.loadScript(JSBundleLoader.java:29)
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager:     at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:258)
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager:     at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1293)
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager:     at com.facebook.react.ReactInstanceManager.access00(ReactInstanceManager.java:131)
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager:     at com.facebook.react.ReactInstanceManager.run(ReactInstanceManager.java:1016)
01-13 17:57:52.142 26389 26472 E unknown:DisabledDevSupportManager:     at java.lang.Thread.run(Thread.java:923)
--------- beginning of crash
01-13 17:57:52.146 26389 26472 E AndroidRuntime: FATAL EXCEPTION: create_react_context
01-13 17:57:52.146 26389 26472 E AndroidRuntime: Process: com.eightsleep.eight, PID: 26389
01-13 17:57:52.146 26389 26472 E AndroidRuntime: 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.
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:234)
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at com.facebook.react.bridge.JSBundleLoader.loadScript(JSBundleLoader.java:29)
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:258)
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1293)
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at com.facebook.react.ReactInstanceManager.access00(ReactInstanceManager.java:131)
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at com.facebook.react.ReactInstanceManager.run(ReactInstanceManager.java:1016)
01-13 17:57:52.146 26389 26472 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:923)

app/build.gradle

project.ext.react = [
    entryFile: "index.js",
    bundleInRelease: true,
    enableHermes: false,
    resourcesDirRelease: "src/release/res"
]

apply from: "../../node_modules/react-native/react.gradle"
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'

build.gradle

dependencies {
   classpath 'com.google.gms:google-services:4.3.4'
   classpath('com.android.tools.build:gradle:4.1.0')
   classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}

我最终通过使用 adb logcat 运行 获取本地发布版本解决了这个问题,发现由于缺少导入而从 Crashlytics 抛出异常。

我只想说,在深入研究文档并将我需要的东西拼凑起来之后。

我在 settings.gradle 中遗漏了这个内容:

include ':@react-native-firebase_app'
project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, './../node_modules/@react-native-firebase/app/android')

此工具的文档保存得很差,我几乎不推荐使用它。