gpt4 book ai didi

javascript - Android:JS Bundle 未从 Metro Bundler 服务器加载

转载 作者:行者123 更新时间:2023-12-05 00:04:26 31 4
gpt4 key购买 nike

在 Android 上,我突然无法让 metro bundler 服务器工作。在过去的 5 个小时里,我一直在调试它,但我找不到导致此问题的任何原因。不同于 this问题,我的应用程序甚至没有开始显示 LogBox 红色错误警告。它会立即崩溃。

每当我尝试运行 Android 应用程序时(我尝试过各种不同的设置,启用/禁用 Hermes,ABI 拆分,明确强制使用 SoLoader 版本,剥离各种代码以获得最小的应用程序,清理 gradle缓存,将 android:usesCleartextTraffic="true" 添加到我的 AndroidManifest.xml 等 ...),该应用程序以白屏启动,然后立即崩溃。我设法在 Logcat 中找到了一些异常:

2020-08-11 11:33:52.315 5176-5256/com.mrousavy.springsale E/GraphResponse: {HttpStatus: 400, errorCode: 100, subErrorCode: 33, errorType: GraphMethodException, errorMessage: Unsupported get request. Object with ID '290453355515078' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api}
2020-08-11 11:33:52.316 5176-5256/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-08-11 11:33:52.316 5176-5264/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-08-11 11:33:52.316 5176-5256/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-08-11 11:33:52.316 5176-5256/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
2020-08-11 11:33:52.346 5176-5279/com.mrousavy.springsale E/ReactNativeJNI: logMarker CREATE_REACT_CONTEXT_END
2020-08-11 11:33:52.347 5176-5274/com.mrousavy.springsale E/unknown:ReactNative: ReactInstanceManager.createReactContext: mJSIModulePackage null
2020-08-11 11:33:52.350 5176-5274/com.mrousavy.springsale 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
2020-08-11 11:33:52.352 5176-5274/com.mrousavy.springsale E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.mrousavy.springsale, PID: 5176
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)
2020-08-11 11:33:52.498 13316-13413/? E/ActivityThread: Failed to find provider info for com.google.android.apps.wellbeing.api
2020-08-11 11:33:52.725 5176-5237/com.mrousavy.springsale D/libcrashlytics: Initializing libcrashlytics version 2.0.5
2020-08-11 11:33:52.725 5176-5237/com.mrousavy.springsale D/libcrashlytics: Initializing native crash handling successful.
2020-08-11 11:33:52.726 5176-5237/com.mrousavy.springsale I/FirebaseCrashlytics: Crashlytics NDK initialization successful
2020-08-11 11:33:52.743 5176-5263/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
2020-08-11 11:33:52.743 5176-5263/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
2020-08-11 11:33:52.743 5176-5263/com.mrousavy.springsale W/FirebaseRemoteConfig: No value of type 'FirebaseRemoteConfigValue' exists for parameter key 'fpr_session_max_duration_min'.
2020-08-11 11:33:52.744 5176-5263/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
2020-08-11 11:33:52.744 5176-5263/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-08-11 11:33:52.744 5176-5263/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
2020-08-11 11:33:52.744 5176-5263/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
2020-08-11 11:33:52.745 5176-5263/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-08-11 11:33:52.745 5176-5263/com.mrousavy.springsale I/chatty: uid=10146(com.mrousavy.springsale) pool-25-thread- identical 1 line
2020-08-11 11:33:52.746 5176-5263/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-08-11 11:33:52.750 5176-5264/com.mrousavy.springsale W/savy.springsal: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-08-11 11:33:52.823 2030-5291/? W/ActivityTaskManager: Force finishing activity com.mrousavy.springsale/.MainActivity
2020-08-11 11:33:52.824 2030-5288/? I/DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
2020-08-11 11:33:52.836 5176-5274/com.mrousavy.springsale I/Process: Sending signal. PID: 5176 SIG: 9
2020-08-11 11:33:52.837 2030-2057/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2020-08-11 11:33:52.838 2030-2057/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2020-08-11 11:33:52.930 2030-2130/? W/InputDispatcher: channel '4b40fe1 com.mrousavy.springsale/com.mrousavy.springsale.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
2020-08-11 11:33:52.930 2030-2130/? E/InputDispatcher: channel '4b40fe1 com.mrousavy.springsale/com.mrousavy.springsale.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2020-08-11 11:33:52.936 2030-3089/? I/WindowManager: WIN DEATH: Window{4b40fe1 u0 com.mrousavy.springsale/com.mrousavy.springsale.MainActivity}
2020-08-11 11:33:52.936 2030-3089/? W/InputDispatcher: Attempted to unregister already unregistered input channel '4b40fe1 com.mrousavy.springsale/com.mrousavy.springsale.MainActivity (server)'
2020-08-11 11:33:52.938 2030-2376/? I/ActivityManager: Process com.mrousavy.springsale (pid 5176) has died: vis+99 TOP

当我使用以下命令手动创建 JS 包时:

npx 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

我设法通过 Android Studio 成功启动了应用程序,但这当然不是解决方案,因为每次更改某些内容(即使在 JS 中)时我都必须运行此命令,所以我没有 live-reload再也没有 console.log,而且我的开发体验很糟糕。

简而言之:我的应用程序无法再通过 localhost 上的 metro bundler 服务器流式传输 bundle ,但是当我手动创建 bundle 时它可以工作。它甚至没有启动 Metro Bundler!在 iOS 上它有效。

最佳答案

所以事实证明这是一个依赖性问题。如果其他人遇到此问题,请将您的项目与"template"项目(在 react-native 存储库中)进行比较,尤其是查看 package.json 中的所有版本!对我来说,我有 metro-config 0.65,这对于 RN 0.63 来说太新了。

关于javascript - Android:JS Bundle 未从 Metro Bundler 服务器加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63356131/

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