这是一个全新的AwesomeProject(rn提供的基本模板)。
我已经根据一切进行了设置 https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment
这是项目android文件夹中的文件列表
app gradle gradlew settings.gradle
build.gradle gradle.properties gradlew.bat
这是gradle文件夹中的文件列表
$cd gradle && ls
wrapper
$cd wrapper && ls
gradle-wrapper.jar gradle-wrapper.properties
$ npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
at checkExecSyncError (child_process.js:610:11)
at execFileSync (child_process.js:628:15)
at runOnAllDevices (/Users/shlokagarwalla/Desktop/programs:projects/mobileapps/you_and_health/AwesomeProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at buildAndRun (/Users/shlokagarwalla/Desktop/programs:projects/mobileapps/you_and_health/AwesomeProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at /Users/shlokagarwalla/Desktop/programs:projects/mobileapps/you_and_health/AwesomeProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Command.handleAction (/Users/shlokagarwalla/.npm/_npx/95900/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:164:9)
I tried manually installing gradle and then running gradle wrapper inside the android folder, and here is the output
$ gradle wrapper
:ReactNative:Unexpected empty result of running 'npx --quiet --no-install react-native config' command from 'null' directory.
:ReactNative:Running 'npx --quiet --no-install react-native config' command from 'null' directory failed.
FAILURE: Build failed with an exception.
* Where:
Script '/Users/shlokagarwalla/Desktop/programs:projects/mobileapps/you_and_health/AwesomeProject/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 170
* What went wrong:
A problem occurred evaluating script.
> java.lang.Exception (no error message)
* 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 1s