我正在将React Native从0.61.5升级到0.64.2,我在运行Android应用时遇到了问题。
这是我在试图启动它时得到的输出。
$ react-native run-android --verbose
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:14959) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 1313 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
debug Running command "cd android && ./gradlew installDebug -PreactNativeDevServerPort=8081"
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
我的安卓环境已经配置好了,我实际上可以运行与react-native
运行的完全相同的命令,而且没有问题。
$ cd android && ./gradlew installDebug -PreactNativeDevServerPort=8081
<-------------> 0% CONFIGURING [7s]
> root project > Resolve dependencies of :classpath > maven-metadata.xml
(gradle最终以成功完成了构建)。
Permissions for gradlew
seem ok:
$ ls -la ./android/gradlew
-rwxr-xr-x 1 mateusz 139652859 5766 20 Jul 13:44 ./android/gradlew
替换代码5】看起来如下。
$ cat android/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
React Native CLI是最新的。
$ react-native --version
react-native-cli: 2.0.1
react-native: 0.64.2
我发现有几个人有类似的问题,但没有一个人是完全相同的。
在仍然使用0.61.5
的main
分支上工作正常。我怀疑这可能只是我没有更新一些配置文件,但是我不知道如何获得一些更详细的提示,说明我到底要改变什么。
有什么想法吗?谢谢!