在Ubuntu中运行React Native App时出错

时间:2019-07-19 10:13:02

标签: android reactjs react-native

我对react-native非常陌生,并且正在尝试通过阅读文档here在react-native中运行我的第一个应用程序。我将我的应用命名为rdvTemp。在react-native run-android中运行命令watchman/rdvTemp时,出现此错误:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
debug Running command "cd android && ./gradlew app:installDebug -PreactNativeDevServerPort=8081"
Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: /home/ankit/.gradle/wrapper/dists/gradle-5.4.1-all/3221gyojl5jsh0helicew7rwx/gradle-5.4.1-all.zip
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

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.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: /home/ankit/.gradle/wrapper/dists/gradle-5.4.1-all/3221gyojl5jsh0helicew7rwx/gradle-5.4.1-all.zip
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

    at checkExecSyncError (child_process.js:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (/home/ankit/watchman/rdvTemp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (/home/ankit/watchman/rdvTemp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:169:41)
    at then.result (/home/ankit/watchman/rdvTemp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:135:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

我知道这意味着安装有问题,但是应该没有错,因为我一直在关注所有事情。我已经安装了Java和Android Studio,安装了Node,对本地CLI和Watchman做出了反应。 Java和Android Studio都是最新的。请告诉我我在做什么错或应该做什么。在其他地方,我无法获得任何帮助。谢谢...

1 个答案:

答案 0 :(得分:0)

第1步:

通过在.grade/dist内找到zip文件,确保已正确安装gradle。

第2步

yourProjectAppDir/android/gradle/wrapper/gradle-wrapper.properties文件中的

将distributionUrl更改为https\://services.gradle.org/distributions/gradle-YOUR_LOCAL_VERSION-all.zip

如果你有 无法锁定任务历史记录缓存(APP_NAME\android\.gradle\YOUR_LOCAL_VERSION\taskHistory),因为此过程已将其锁定。

您可能需要通过删除.gradle \ caches文件夹来清除缓存