Reputation: 551
I'm using react-native 0.43.3 on OSX. I tried to running app on Android and get message
react-native run-android
Scanning 568 folders for symlinks in /Users/ruci.k/project/mayacrew/supermembers/supermembers/node_modules (5ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
./gradlew installDebug gave me some errors and fixed it all. Finally build get successed and app is working on Android device.
But react-native run-android
command still not work.
Only ./gradlew installDebug
command work.
Is there anything can I check to use react-native run-android
command?
I can't understand how could it happened.
Upvotes: 45
Views: 243499
Reputation: 61
as for me working on apple m1 I had to change the path to the following:
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"
just a change in the path in case it didn't work with
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
Upvotes: 0
Reputation: 417
Check the error messages carefully. It will give a clue to what went wrong. In my case, after installing expo in my react-native project, the MainApplication.java got corrupted. I made a comparison with the a backup (you can check an earlier working commit), then removed the erroring lines.
After this, it worked.
Upvotes: 0
Reputation: 928
After you create your react native app ,try
sudo chmod -R 777 node-modules
sudo chmod -R 777 android
export ANDROID_HOME=~/Library/Android/sdk
now run
react-native run-android
Upvotes: 21
Reputation: 21
What worked for me is,
Uninstalling the previous installed app version on the emulator device, and running react-native run-android
after.
Upvotes: 0
Reputation: 1
For me, this had to do with running low on RAM om my Mac.
in gradle.properties put -XX:MaxPermSize=4096
for example like this:
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m
After that, it runs again.
Upvotes: 0
Reputation: 21462
this issue come from two reasons
1- Permission issue
How to Fix it
sudo react-native run-android
Or
chmod 755 android/gradlew
2- Mismatch java version with Gradle
make sure you are using Java 8 as $JAVA_HOME
environment variable
depending on which terminal you are using to run your code at
For zsh shell, export $JAVA_HOME at ~/.zshenv or ~/.zshrc. For bash shell, export $JAVA_HOME at ~/.bash_profile or ~/.bashrc.
get installed JDK by this command
/usr/libexec/java_home -V
example for using zsh
vi ~/.zshrc
// paste the java export inside it
export JAVA_HOME="JDK_8_Path_from_previous command"
to save your change
:x
make sure your changes applied
source ~/.zshrc
now for testing
echo $JAVA_HOME
Upvotes: 3
Reputation: 1354
I have to perform these steps to get it running.
Upvotes: 0
Reputation: 1
1 . you should have space in your phone
2 . developer option on
3 . USB debugging option also on
4 . check "adb devices" devices is connected or not
Upvotes: 0
Reputation: 452
cd android && sudo ./gradlew clean
This worked for me. Try it out and let me know if it helps folks
Upvotes: 12
Reputation: 1
So here are the three solution for this bug , from which one will most probably solve your issue :
1: Adding local.properties file in your android folder
https://stackoverflow.com/questions/32634352/react-native-android-build-failed-sdk-location-not-found
2: Try deleting .gradle file and then build (react-native run-android)
3: Might be possible that under SDK tools NDK(side by side) and CMake are not installed . Steps for the same is Android Studio which include direction for opening sdk manager
Open android folder in Android Studio Click on the SDK Manager (which is at the third position from the top left )
After opening SDK manager you have to go to SDK Tools Installation image for NDK and CMake
Under SDK Tools select NDK(side by side) and CMake and press the okay button and let the installation complete . After the close the Android Studio and react-native run-android.
Upvotes: 0
Reputation: 505
Running
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
worked for me
Upvotes: 38
Reputation: 1303
Upvotes: 0
Reputation: 41
I had the same issue, and just opened the project in android studio, and that's all. Solved!
Upvotes: 3
Reputation: 11
Upvotes: 1
Reputation: 2962
Try removing android,ios folders and then do react-native upgrade
then try again react-native run-android
After that if you get an error like
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
then create a file named local.properties inside the folder
android
and insert the following line sdk.dir =/path/to/Android/Sdk
After this everything should be fine
Note: If you have made some changes in android/ios folder please keep its backup before removing the folders
Upvotes: 16
Reputation: 9558
Run the following command
chmod 755 android/gradlew
inside your app root folder then run
react-native run-android
Upvotes: 34
Reputation: 1
So what i did was to download this jar file from: 1: https://drive.google.com/file/d/1MHSJx-_0RHRzlrXBLAePKeWKQteke0Um/view?usp=sharing and placed it inside android/gradle/wrapper
then i went back to the project directory and did npm install
i then changed directory to android by doing: cd android
then i ran the following commands
chmod +x ./gradlew
xattr -l ./gradlew
Now i went back to the project directory and ran react-native run-android
Upvotes: 0
Reputation: 49
In Ubuntu, I have used this command and it worked for me:
sudo react-native run-android
Upvotes: 4
Reputation: 547
I have faced the same issue when I have imported the project from the GitHub.
Follow the below steps to run your react-native project in the Android device from the MAC OS
npm install
Move to the android folder in the project root folder.
cd android
Run the following commands one after another to give permissions to gradlew file.
chmod +x ./gradlew
xattr -l ./gradlew
xattr -d com.apple.quarantine ./gradlew
react-native run-android
Now you can see the launched application on your connected Android device/emulator.
Upvotes: 4
Reputation: 41
Check whether your emulator is connected or not:
set ANDROID_HOME path: E:\android-sdk-windows
set path D:C:\Program Files\nodejs;C:\Program Files\Java\jdk1.8.0_111\bin;E:\android-sdk-windows\platform-tools
Upvotes: 2
Reputation: 613
You must change your build.gradle:
compileSdkVersion 28
buildToolsVersion "28.0.2"
minSdkVersion 16
targetSdkVersion 27
and add this line:
implementation "com.android.support:appcompat-v7:28.0.0"
Upvotes: 2
Reputation: 846
maybe install watchman?
https://github.com/facebook/react-native/issues/10056
Otherwise, for me I actually use 'npm start' inside of the folder. npm will know to run the right command to start react native because it's in a react native directory.
Upvotes: 0