This error occurred when trying to run npx react-native run-android
error encountered
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.
cd android (you can also go directly to project/android folder and open cmd there)gradlew clean (for modern versions: ./gradlew clean)chmod +x gradlewIf 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,
https://www.oracle.com/java/technologies/javase-jdk14-downloads.htmlyour_project/android/gradle/wrapper/gradle-wrapper.propertiesdistributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zipnpx react-native run-androidthis worked for me.