Timeout waiting to lock artifact cache. It is currently in use by another Gradle instance. React Native Android Gradle Error Fix

I stumbled upon the following react native issue when I was trying to run one of my react native projects on the Android emulator.

Could not resolve all dependencies for configuration ‘:classpath’. > Timeout waiting to lock artifact cache (/home/rashid/.gradle/caches/modules-2). It is currently in use by another Gradle instance. Owner PID: 19520 Our PID: 24483 Owner Operation: Our operation: Lock file: /home/rashid/.gradle/caches/modules-2/modules-2.lock

react native gradle error

Reading the error itself you can understand that the issue is with the Gradle instance. To solve this lock issue you should delete the lock file. The lock file location is already given in the error.

For example, the location of my lock file is /home/rashid/.gradle/caches/modules-2/modules-2.lock. After deleting the file run cd android && ./gradlew clean command. Now re-run your react native project and your build will not be failed due to this error.

Leave a Reply

%d bloggers like this: