有一天,我将本机反应项目从0.59.3升级到0.60.2 设置AndroidX迁移并运行react-native run-android。 它显示“构建成功”,并且该应用已安装在模拟器上,但Metro bundler无法运行
有我的设置:
react-native-cli:2.0.1 反应本机:0.60.2
这是登录终端
warn The following packages use deprecated "rnpm" config that will stop working from next release:
- react-native-code-push: https://microsoft.github.io/code-push
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
- @react-native-community/async-storage (to unlink run: "react-native unlink @react-native-community/async-storage")
- react-native-amplitude-analytics (to unlink run: "react-native unlink react-native-amplitude-analytics")
- react-native-camera (to unlink run: "react-native unlink react-native-camera")
- react-native-code-push (to unlink run: "react-native unlink react-native-code-push")
- react-native-config (to unlink run: "react-native unlink react-native-config")
- react-native-firebase (to unlink run: "react-native unlink react-native-firebase")
- react-native-languages (to unlink run: "react-native unlink react-native-languages")
- react-native-os (to unlink run: "react-native unlink react-native-os")
- react-native-randombytes (to unlink run: "react-native unlink react-native-randombytes")
- react-native-splash-screen (to unlink run: "react-native unlink react-native-splash-screen")
- react-native-svg (to unlink run: "react-native unlink react-native-svg")
- react-native-tcp (to unlink run: "react-native unlink react-native-tcp")
- react-native-touch-id (to unlink run: "react-native unlink react-native-touch-id")
- react-native-udp (to unlink run: "react-native unlink react-native-udp")
- react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons")
- react-native-version-number (to unlink run: "react-native unlink react-native-version-number")
- react-native-webview (to unlink run: "react-native unlink react-native-webview")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1351 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
> Configure project :@react-native-community_async-storage
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :app
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
Reading env from: .env
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Configure project :react-native-amplitude-analytics
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-camera
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-code-push
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-config
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-firebase
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
react-native-firebase: using React Native prebuilt binary from /Users/mac/Documents/GitHub/myrn/node_modules/react-native/android
> Configure project :react-native-keychain
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-languages
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-os
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :react-native-randombytes
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-splash-screen
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-svg
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :react-native-tcp
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :react-native-touch-id
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-udp
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :react-native-vector-icons
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-version-number
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
> Configure project :react-native-webview
WARNING: The following project options are deprecated and have been removed:
android.enableAapt2
This property has no effect, AAPT2 is now always used.
WARNING: The option setting 'android.enableD8.desugaring=false' is experimental and unsupported.
The current default is 'true'.
:react-native-webview:reactNativeAndroidRoot /Users/mac/Documents/GitHub/myrn/node_modules/react-native/android
> Task :app:processDebugGoogleServices
Parsing json file: /Users/mac/Documents/GitHub/myrn/android/app/google-services.json
> Task :app:installDebug
12:04:15 V/ddms: execute: running am get-config
12:04:15 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1
12:04:15 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'Nexus_5X_API_28(AVD) - 9' for app:debug
12:04:15 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
12:04:16 D/Device: Uploading file onto device 'emulator-5554'
12:04:16 D/ddms: Reading file permision of /Users/mac/Documents/GitHub/myrn/android/app/build/outputs/apk/debug/app-debug.apk as: rw-r--r--
12:04:16 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
12:04:16 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
12:04:16 V/ddms: execute: returning
12:04:16 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
12:04:16 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
12:04:16 V/ddms: execute: returning
Installed on 1 device.
BUILD SUCCESSFUL in 5s
338 actionable tasks: 7 executed, 331 up-to-date
info Connecting to the development server...
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.dapppocket/.MainActivity }
答案 0 :(得分:0)
检查当前进程是否已经启动并在任何端口上运行
STEP 1
以管理员身份运行命令行。然后运行以下提及的命令。在yourPortNumber中输入您的端口号
netstat -ano | findstr :yourPortNumber
它将列出进程及其PID(进程标识符)
然后,您在识别PID后执行此命令。
taskkill /PID typeyourPIDhere /F
注意: 由于taskkill在某些git bash命令中不起作用,请尝试:
tskill typeyourPIDhere
再次运行第一个命令以检查该进程是否仍然可用。如果该过程成功结束,您将得到一个空行。
第2步
有时在升级RN版本时也会出现类似的问题。我还没有找到解决方案,但意识到在成功构建之前有必要进行清理。
到目前为止,对我来说最好的解决方案是启动该项目的批处理脚本,其中包括gradlew clean
cd (path to project/android folder)
gradlew clean
cd (path to project root folder)
react-native run-android
注意:可以通过以下方式将所有4个命令组合在一起
cd (path to project/android folder) && gradlew clean && cd (path to project root folder) && react-native run-android
你很好走
希望这有助于解决您的问题。