我使用该 npx react-native init MyApp --template react-native-template-typescript
命令启动了一个新项目,然后我运行命令 react-native start
,当我尝试运行 android 时,我收到该错误:
E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (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:263)
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:1023)
at java.lang.Thread.run(Thread.java:923)
我尝试通过命令和 Android Studio 来解决它,但两者都不起作用。
对于ios我第一次体验Command PhaseScriptExecution failed with a nonzero exit code
,
但是我的电脑重启后就消失了。
请帮忙
React Native 版本:
System: OS: macOS 11.4
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Memory: 197.63 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 15.9.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.5.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK:
API Levels: 28, 29, 30
Build Tools: 28.0.3, 29.0.2, 30.0.3
System Images: android-29 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.7042882
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_282 - /usr/bin/javac
重现步骤