【发布时间】:2021-12-01 03:25:03
【问题描述】:
所以我刚刚使用 '$ npx react-native init tracking' 创建了一个反应原生应用程序'tracks',当我尝试运行命令 '$ npx react-native run- android',它显示以下错误。我尝试将类路径 gradle 版本(默认 4.2.2)更改为许多其他版本,但没有用。 几天来我一直无法绕过它。请帮忙**
CMD:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 871 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\utsar\Desktop\ReactProjects\tracks\android\app\build.gradle' line: 3
* What went wrong:
Could not compile build file 'C:\Users\utsar\Desktop\ReactProjects\tracks\android\app\build.gradle'.
> startup failed:
build file 'C:\Users\utsar\Desktop\ReactProjects\tracks\android\app\build.gradle': 3: unable to resolve class com.android.build.OutputFile
@ line 3, column 1.
import com.android.build.OutputFile
^
1 error
* 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 6s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\utsar\Desktop\ReactProjects\tracks\android\app\build.gradle' line: 3
* What went wrong:
Could not compile build file 'C:\Users\utsar\Desktop\ReactProjects\tracks\android\app\build.gradle'.
> startup failed:
build file 'C:\Users\utsar\Desktop\ReactProjects\tracks\android\app\build.gradle': 3: unable to resolve class com.android.build.OutputFile
@ line 3, column 1.
import com.android.build.OutputFile
^
1 error
* 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 6s
at makeError (C:\Users\utsar\Desktop\ReactProjects\tracks\node_modules\execa\index.js:174:9)
at C:\Users\utsar\Desktop\ReactProjects\tracks\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async runOnAllDevices (C:\Users\utsar\Desktop\ReactProjects\tracks\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:106:5)
at async Command.handleAction (C:\Users\utsar\Desktop\ReactProjects\tracks\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
【问题讨论】:
标签: android react-native gradle