0

This error occurred when trying to run npx react-native run-android error encountered

AMAL MOHAN N
  • 1,416
  • 2
  • 14
  • 26

1 Answers1

5

I've figured a way to resolve this issue. To resolve this please follow the following steps. Here we'll be trying two steps, if you're lucky the issue will resolve in first step it self.

  1. go to the project folder
  2. open cmd in that folder (if you're using vscode use cntrl + ~ to open terminal)
  3. cd android (you can also go directly to project/android folder and open cmd there)
  4. now run gradlew clean (for modern versions: ./gradlew clean)
  5. if you get permission errors then try chmod +x gradlew

If your issue is resolved have a good coding else continue. Most common error is java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

for resolving this please following the below steps,

  1. Please download JDK version 14 or above JDK Download link: https://www.oracle.com/java/technologies/javase-jdk14-downloads.html
  2. go to your_project/android/gradle/wrapper/gradle-wrapper.properties
  3. change to gradle version 6.3 or above distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
  4. now run npx react-native run-android

this worked for me.

Community
  • 1
  • 1
AMAL MOHAN N
  • 1,416
  • 2
  • 14
  • 26