尝试使用以下文档中的打字稿设置基本应用程序:
react-native init MyAwesomeProject --template typescript
logcat在启动我的应用程序时向我显示此错误:
2019-09-20 10:58:32.710 5630-5850/com.tcapp E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.tcapp, PID: 5630
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/react/views/webview/ReactWebViewManager;
at com.facebook.react.PackageList.getPackages(PackageList.java:65)
at com.tcapp.MainApplication$1.getPackages(MainApplication.java:27)
at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:78)
at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:41)
at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:91)
at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:80)
at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:52)
at android.app.Activity.performCreate(Activity.java:7327)
at android.app.Activity.performCreate(Activity.java:7318)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3094)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3257)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1948)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7050)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.views.webview.ReactWebViewManager" on path: DexPathList[[zip file "/data/app/com.tcapp-qPigk7PZTn_eAZ0A9Nm4ew==/base.apk"],nativeLibraryDirectories=[/data/app/com.tcapp-qPigk7PZTn_eAZ0A9Nm4ew==/lib/arm64, /data/app/com.tcapp-qPigk7PZTn_eAZ0A9Nm4ew==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.facebook.react.PackageList.getPackages(PackageList.java:65)
at com.tcapp.MainApplication$1.getPackages(MainApplication.java:27)
at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:78)
at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:41)
at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:91)
at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:80)
at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:52)
at android.app.Activity.performCreate(Activity.java:7327)
at android.app.Activity.performCreate(Activity.java:7318)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3094)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3257)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1948)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7050)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
包装json:
{
"name": "tcapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-native-community/async-storage": "^1.6.1",
"react": "16.8.6",
"react-dom": "^16.9.0",
"react-native": "0.60.5",
"react-native-circular-progress": "^1.3.0",
"react-native-component-fade": "^1.0.2",
"react-native-elements": "^1.2.0",
"react-native-fade": "^1.0.3",
"react-native-fade-in-view": "^1.0.5",
"react-native-gesture-handler": "^1.4.1",
"react-native-responsive-image": "^2.3.1",
"react-native-searchbar": "^1.16.0",
"react-native-share": "^2.0.0",
"react-native-splash-screen": "^3.2.0",
"react-native-svg": "^9.9.4",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "^7.0.6",
"react-native-webview-bridge": "^0.40.1",
"react-native-youtube": "^2.0.0-beta.2",
"react-navigation": "^4.0.5",
"react-navigation-backhandler": "^1.3.2",
"react-navigation-transitions": "^1.0.12",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/runtime": "^7.5.0",
"@react-native-community/eslint-config": "0.0.3",
"@types/jest": "^24.0.18",
"@types/react": "^16.9.2",
"@types/react-native": "^0.60.14",
"@types/react-test-renderer": "^16.9.0",
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.6",
"redux-logger": "^3.0.6",
"typescript": "^3.6.3"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}