无法再在Emulator上运行React Native Project


由于某些原因,我的应用程序无法在AS Emulator上启动。昨天一切都很好,但今天不行了——可能是因为我移动了npm和npm缓存文件夹,但它们是用npm配置正确设置的。

Metro服务器启动正常,如果我刚刚选择了应用程序,它会加载它,但现在它会崩溃。。

如果我尝试运行npm android,我会得到以下错误:

PS C:DevProgrammierungFitnessAppFitnessApp> npm run android
> FitnessApp@0.0.1 android C:DevProgrammierungFitnessAppFitnessApp
> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1158 file(s) to forward-jetify. Using 6 workers...
info Starting JS server...
Der Befehl "adb" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :app:transformClassesWithDexBuilderForDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
147 actionable tasks: 3 executed, 144 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> Unable to delete directory 'C:DevProgrammierungFitnessAppFitnessAppandroidappbuildintermediatestransformsdexBuilderdebugandroidxappcompat' after 10 attempts
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 17s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> Unable to delete directory 'C:DevProgrammierungFitnessAppFitnessAppandroidappbuildintermediatestransformsdexBuilderdebugandroidxappcompat' after 10 attempts
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 17s
at makeError (C:DevProgrammierungFitnessAppFitnessAppnode_modulesexecaindex.js:174:9)
at C:DevProgrammierungFitnessAppFitnessAppnode_modulesexecaindex.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async runOnAllDevices (C:DevProgrammierungFitnessAppFitnessAppnode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:94:5)
at async Command.handleAction (C:DevProgrammierungFitnessAppFitnessAppnode_modulesreact-nativenode_modules@react-native-communityclibuildindex.js:186:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! FitnessApp@0.0.1 android: `react-native run-android`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the FitnessApp@0.0.1 android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:Devnpmnpm-cache_logs2020-04-24T08_01_58_811Z-debug.log

我的修正是:

cd安卓

/gradlew清洁

并两次重建应用程序

最新更新