React Native应用在发布模式下崩溃,但在调试模式下正常运行。

huangapple go评论68阅读模式
英文:

React Native App crashing on release mode but working fine debug mode

问题

我的React Native应用几天前在发布和调试模式下都能正常运行,但从昨天开始,在发布模式下启动后就会不断崩溃,但在调试模式下完全正常。

当我运行

adb logcat *:E

它给了我以下日志,但我在互联网上找不到相关的信息

02-17 18:30:56.108   564   595 E libPowerHal: 无法打开 '/proc/1705/comm'
02-17 18:30:56.108   564   595 E libPowerHal: 错误: 13, 权限被拒绝
02-17 18:30:56.260 22398 22398 E com.blackhedge: 由于进程无法加载jdwp代理,不启动调试器。
02-17 18:30:56.282   564   595 E libPowerHal: perfLockRel句柄: 293
02-17 18:30:56.517 22398 22398 E libc    : 拒绝访问查找属性 "ro.vendor.df.effect.conflict"
02-17 18:30:56.518   534 22445 E ResolverController: 无有效的NAT64前缀 (105, <unspecified>/0)
02-17 18:30:56.518   534 22447 E ResolverController: 无有效的NAT64前缀 (105, <unspecified>/0)
02-17 18:30:56.518   534 22446 E ResolverController: 无有效的NAT64前缀 (105, <unspecified>/0)
02-17 18:30:56.597   564   595 E libPowerHal: perfLockRel句柄: 294
02-17 18:30:56.716  1204  1687 E WindowManager: 应用试图使用不安全的INPUT_FEATURE_NO_INPUT_CHANNEL标志。忽略
02-17 18:30:56.716   534 22467 E ResolverController: 无有效的NAT64前缀 (105, <unspecified>/0)
02-17 18:30:56.720 22398 22454 E AndroidRuntime: 致命异常:create_react_context
02-17 18:30:56.720 22398 22454 E AndroidRuntime: 进程:com.blackhedge,PID:22398
02-17 18:30:56.720 22398 22454 E AndroidRuntime: java.lang.RuntimeException: 无法加载脚本。确保你要么运行Metro(运行'npx react-native start'),要么你的捆绑包'index.android.bundle'被正确打包为发布。
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:239)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:268)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1371)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:136)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1065)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:919)
02-17 18:30:56.730 22398 22457 E fullstory: 销毁扫描器被调用两次
02-17 18:30:56.809  1204  1329 E InputDispatcher: 通道'81fad7a com.blackhedge/com.blackhedge.MainActivity(服务器)' ~ 通道无法恢复并将被丢弃!
02-17 18:30:56.812  4731  4790 E PowerKeeper.Event: 哎呀,解析AM_RESTART_ACTIVITY_AI参数错误
02-17 18:30:56.814  1204  1343 E WifiVendorHal: getWifiLinkLayerStats_1_3_Internal(l.927) 失败 {.code = ERROR_NOT_SUPPORTED, .description = }
02-17 18:30:57.182  1705  1705 E Launcher: changeViewByFsGestureState,view=ShortcutMenuLayer,alpha=1.0,scale=1.0
02-17 18:30:57.233   564   595 E libPowerHal: perfLockRel句柄: 295
02-17 18:30:59.825  1204  1343 E WifiVendorHal: getWifiLinkLayerStats_1_3_Internal(l.927) 失败 {.code = ERROR_NOT_SUPPORTED, .description = }

我尝试生成日志并在互联网上搜索日志中出现的错误,但没有找到任何信息。

英文:

My React native app was working fine few days back on both release and debug mode but from yesterday it keeps crashing on start in release mode, but it is working perfectly fine on debug mode.
When i ran

adb logcat *:E

it gave me following logs but i can't find anything on internet related to this

02-17 18:30:56.108   564   595 E libPowerHal: Could not open '/proc/1705/comm'
02-17 18:30:56.108   564   595 E libPowerHal: error : 13, Permission denied
02-17 18:30:56.260 22398 22398 E com.blackhedge: Not starting debugger since process cannot load the jdwp agent.
02-17 18:30:56.282   564   595 E libPowerHal: perfLockRel handle:293
02-17 18:30:56.517 22398 22398 E libc    : Access denied finding property "ro.vendor.df.effect.conflict"
02-17 18:30:56.518   534 22445 E ResolverController: No valid NAT64 prefix (105, <unspecified>/0)
02-17 18:30:56.518   534 22447 E ResolverController: No valid NAT64 prefix (105, <unspecified>/0)
02-17 18:30:56.518   534 22446 E ResolverController: No valid NAT64 prefix (105, <unspecified>/0)
02-17 18:30:56.597   564   595 E libPowerHal: perfLockRel handle:294
02-17 18:30:56.716  1204  1687 E WindowManager: App trying to use insecure INPUT_FEATURE_NO_INPUT_CHANNEL flag. Ignoring
02-17 18:30:56.716   534 22467 E ResolverController: No valid NAT64 prefix (105, <unspecified>/0)
02-17 18:30:56.720 22398 22454 E AndroidRuntime: FATAL EXCEPTION: create_react_context
02-17 18:30:56.720 22398 22454 E AndroidRuntime: Process: com.blackhedge, PID: 22398
02-17 18:30:56.720 22398 22454 E AndroidRuntime: java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:239)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:268)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1371)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:136)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1065)
02-17 18:30:56.720 22398 22454 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:919)
02-17 18:30:56.730 22398 22457 E fullstory: Destroy scanner called twice
02-17 18:30:56.809  1204  1329 E InputDispatcher: channel '81fad7a com.blackhedge/com.blackhedge.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
02-17 18:30:56.812  4731  4790 E PowerKeeper.Event: oops, parse AM_RESTART_ACTIVITY_AI parameter error
02-17 18:30:56.814  1204  1343 E WifiVendorHal: getWifiLinkLayerStats_1_3_Internal(l.927) failed {.code = ERROR_NOT_SUPPORTED, .description = }
02-17 18:30:57.182  1705  1705 E Launcher: changeViewByFsGestureState,  view=ShortcutMenuLayer,  alpha=1.0,  scale=1.0
02-17 18:30:57.233   564   595 E libPowerHal: perfLockRel handle:295
02-17 18:30:59.825  1204  1343 E WifiVendorHal: getWifiLinkLayerStats_1_3_Internal(l.927) failed {.code = ERROR_NOT_SUPPORTED, .description = }

I tried generating logs and searched on internet the errors i was getting on logs but found nothing

答案1

得分: 0

这个错误是由于在./android/app/src/main/assets目录中缺少index.android.bundle文件导致的。

第一步:

如果android/app/src/main/目录中不存在assets文件夹,请创建它。

第二步:

运行以下命令行:

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

第三步:

以发布模式编译应用程序。

英文:

this error is caused by the absence of the index.android.bundle file in the ./android/app/src/main/assets directory

First step:

Create the assets folder if it does not exist in the android/app/src/main/ directory

Second step:

Run the following command line:

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

Step three:

Compile the application in release mode

huangapple
  • 本文由 发表于 2023年2月18日 13:32:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75491412.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定