I was working on a local project from scratch which was not on github and it was running successfully. But when i clone a project from github and try to run on android, mostly (not every application cloned from github gives me this error but few big application gives) it gives me error like
Command That I run:
npx react-native run-android
Error that I get:
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
This is because you have to download the gradle files first before running it. Follow the steps and it will definitely run.
Step 1: Clone the project from github repo.
Step 2: Open it in any
code editor (I prefer VS code).
Step 3: Install node_modules by
running npm install command in terminal.
Step 4: Open android
studio and open the react-native-app/android folder inside it.
Note: Android Studio will automatically start downloading the gradle and build it, which you can see in bottom part of android studio.
Step 5: After gradle files are downloaded and build successfully, go back to the code editor and try to run your app again using
npx react-native run-android
Note: If it shows the same error restart your code editor or laptop and it will work like a charm.
make sure you have configure the environment of react native in your machine(desktop/laptop).
follow the link for environment Setup:
https://reactnative.dev/docs/environment-setup
after that follow below steps:
Clone the project from github.
cd projectName
npm install
npx react-native run-android
Clone the project and Open that folder
--> npm install
--> cd ios -> pod install
--> gradle wrapper
--> npx react-native run-android
I create a react native app in C9. Now, I want to develop this app on my local machine with android settings. I downloaded the project.
cd myProjectFolder
react-native start
npm install
react-native run-android
Also, I add a project name in package.json.
The error is below:
error Android project not found. Are you sure this is a React Native project?
If android project/folder does not exit in your root project then run :
react-native eject
I encountered this issue after I ruan ./gradlew clean. Tried serval methods but vain. Then I ran ./gradlew in the Android directory. It worked for me.
// Android
./gradlew
I initialized a react-native app with react-native init xxx and installed the latest(v4.1.0). Android Studio could not complete sync. it says:
When I run react-antive run-android from console, it says something similar.
I tried to wget the kotlin gradle plugin, it was not there. :'(
How to reproduce?
Just initialize a react-native(0.58) app
Run yarn install react-native-webview . // version 4.1.0
run react-native run-android
So this is a deadlink:
https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.11/kotlin-gradle-plugin-1.3.11.pom
I find it's here.
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.11/kotlin-gradle-plugin-1.3.11.pom
Please Note version 1.3.20 is also available.
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.20/kotlin-gradle-plugin-1.3.20.pom
Please help :'(
Thanks in advance.
Steps:
Delete .idea folder and .iml in android directory
In Android Studio -> Build -> Clean
File -> Invalidate Caches / Restart
I learning React-Native with Windows 10, Using Git Bash Command Prompt and Android Studio Emulator.
I have Install React Native globally by using npm install -g react-native-cli, I always create Project using react-native init ProjectName and
My Project Launching Method is
go into Project Directory with Git Bash CMD and execute react-native run-android.
I notice that most of the Project in Github are older version which consist of index.android.js and index.ios.js (My Project is newer version so it only have index.js). I been trying to open some older version Project, but it seem like it just does not launch with the method I mentioned above.
I also have tried react-native start method from How to open existing project in React Native? but I still not able to launch it.
The error message when I trying to launch the project is Command unrecognized. Make sure that you have run npm install and that you are inside a react-native project. This Problem only occur when I trying to launch project from Github, when I open my own Project there is no such problem.
ps. If I try use npm install in the project directory, it will have some error.
I have try to search from Net, most of their launching method are the same as above and does not work for me, so wanna ask that:
Is my method of launching React-Native is wrong in the very beginning?
Is there anything I need to install so that I can open old version React Native Project?
How can I open this project with my current situation? https://github.com/parkerdan/SampleNavigation
Thank you.
Extra Info (React Native CLI and Node Version):
$ react-native -v
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory
> process.version
'v8.9.4' (Node Version)
After whole day of Searching, I have found the Solution.
Whenever open any Project from Github or any sources, we have to ensure that the we have install all the required Dependencies, as Most of the Project using different type of dependencies that you may have not ever install.
Solution:
Download project
git clone https://github.com/parkerdan/SampleNavigation.git
2. Go to the Project Directory and Install dependencies (IMPORTANT)
Note: For unknown reason, npm install does not work
npm i
or yarn i
Run Project (or any launch method that work you)
react-native run-android
After you clone your project from git and cd to project folder, make sure you run npm install before you can react-native run-android.
I am trying to develop a Android application using Android Studio,
so I created an Android app and I want to publish it.
Whenever I click on “build project“ to obtain the apk file,
I get this error:
Error:Execution failed for task ':app:processDebugResources'.
> java.io.IOException: Could not delete folder C:\Users\ehsan\AndroidStudioProjects\MyApplication3\app\build\generated\source\r\debug\com\example\ehsan
Build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.ehsan.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
}
REACT NATIVE
From your react native folder run:
cd android && gradlew clean
THEN
cd .. && react-native run-android
Notes:
For mac you may need to change gradlew to ./gradlew
For the command prompt you may need to change the && to &
For powershell you may need to change the && to ; and gradlew to .\gradlew.bat
Each command can also be run individually like so cd android then gradlew clean then cd .. then react-native run-android
I guess some of the files in the target build directory is open in another tool you use. Just a file handle open in the folder which has to be cleaned. The build task 'clean' wants to delete all the files in the build directory(normally 'target') and when it fails, the build fails.
Just clean your project, it works for me.
Clean task for gradle will work.
Fix This issue by this command
In Windows Platform
cd android && gradlew clean && cd..
In Mac Platform
cd android && ./gradlew clean && cd ..
Fix is very simple: Just follow below instructions
First, save the project
Click on project folder
Click on Syncronize button in the menubar (The third icon from the left which is just below to File menu option)
Clean project and run
as others have said allready you need to clean your project , the steps to clean the project are:
Build -> Clean Project or Build -> Rebuild Project
In my case, that problem is about permissions. if you open android studio as administrator (or using sudo) then if you open the project again as normal user, android studio may not delete some files because when you open the project as administrator, some project files permissions are changed. If you lived those steps, I think you should clone the project from your VCS (git, tfs, svn etc.) again. Otherwise you have to configure project file - folder permissions.
I have same issue. When I clean my project and rebuild it then everything works fine.
Build -> Clean Project
Just clean your project (Android Studio>Build>Clean Project) and build again.
I found another handy solution, which avoids rebuilding all components again and again, in this article:
http://bitstopixels.blogspot.ca/2017/04/react-native-windows-10-eperm-operation.html
Execute react-native run-android
As soon as React Packager window opens, close it
Wait for react-native run-android to complete giving you the BUILD SUCCESSFUL message. (The app will be launched with a red error screen complaining connecting to server failed. Don't panic.)
Then run react-native start to start the React Packager, this is the server indicated in the error message of the previous step
Reload the app in emulator or device (Double tap the R key)
If you encountered these errors due to opening the android studio with sudo command, then the solution is setting permission for the project folder.
Run the command below.
sudo chmod -R 777 your_project_folder
clean and rebuild again your android project.
React Native
These steps solved my problem:
Renaming of ReactNativeApp/android/build directory to old.build
Closing Android Studio
Inside ReactNativeApp/android executed this command.
gradlew clean
Making sure my RAM is 1500mb free
Then finally executing the command
react-native run-android
** It's quite interesting to close Android Studio. But beleive me these steps solved my problem **
Stopping OpenSdk Java process (inner to Android Studio process) worked.
If you have another instance of Android Studio running, then kindly close it and then build the app. This worked in my case
If you are using macOS then => sudo ./gradlew clean will work for you.
I deleted folder app/build and the problem was resolved in my case.
Update your gradle version.
Go to your project level build.gradle file and make sure you are using the latest version of gradle.
React Native
In my case I just refresh ( http://localhost:8081/debugger-ui/ ) , and it works... Any other solutions didn't work for me. Perhaps some files are used by debuger and it can't delete them... Anyway, it works for me. Please try this and give a feedback.
If it says:
The term 'gradlew' is not recognized
Then using following command
npm start -- --reset-cache
worked for me. cheers!
Delete android/app/build folder and run react-native run-android
From my experience in React Native, you can also restart your CLI and this error goes away.
I'm working on windows 10 and i can't find gradlew i cleaned the project using Android Studio :
Build ---> clean project and after that i was able to run :
react-native run-android or to run project using Android Studio
i just delete the error package from package.json and run again gradlew clean and its works for me For React Native
In my case it was that you had the app installed and when you gave it react-native run-android I could not install the app since it was already previously installed
Try closing your text editor (maybe VS Code) and File Explorer and run the command again in terminal with admin permissions.
Just Do onething File->Invalidate caches/ restart.
After loading the project sync the project.