Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am very new to react-native, and was trying to run my first app in react-native by reading the docs here . I named my app rdvTemp . When I run the command react-native run-android in watchman/rdvTemp , I get this error:

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)

I understood that it means there's something wrong with installation, but it shouldn't have been so because I followed everything. I installed Node, react native CLI and watchman while I already had Java and Android Studio. Both Java and Android Studio are upto date. Please tell me what am I doing wrong or what should I do. I was unable to get any help on this elsewhere. Thanks...

step 1 :

make sure you have correctly installed gradle by locating the zip file inside .grade/dist

step 2

in yourProjectAppDir/android/gradle/wrapper/gradle-wrapper.properties file change the distributionUrl to https\://services.gradle.org/distributions/gradle-YOUR_LOCAL_VERSION-all.zip

if you got Cannot lock task history cache (APP_NAME\android\.gradle\YOUR_LOCAL_VERSION\taskHistory) as it has already been locked by this process.

you may need to clear the cache by removing the .gradle\caches folder

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.