I trying to run the react-native run-android through my React Project. After that,
I got this error
If you are installed sdk correctly, you can create an empty file in your android project named "local.properties" (if it does not exist) and define sdk address in it like this:
sdk.dir=/home/USERNAME/Android/Sdk
This address may changes based on your settings, it's the default address in linux.
I hope it helps you
I assume that you are using windows.
Add an environment variable ANDROID_HOME that points to
C:\Users\<your-user-name>\AppData\Local\Android\Sdk
You must follow the steps described in the URL:
https://facebook.github.io/react-native/docs/getting-started.html
go to Building Project with native Code and follow the steps and you must have a virtual or real device for testing. To check if any device is connected or not just go to your terminal and type adb devices and if there is any device it will show.
Related
I was trying execute myapp to android but an error occurred.
To clarify what happened, first time I install nodejs and Android Studio.
Later I used the following commands:
npx react-native init 'app'
cd app
npx react-native run-android
Its my fisrt time messing with react native, I was following this page:
https://learn.microsoft.com/pt-br/windows/dev-environment/javascript/react-native-for-android
And the error is:
The error
I want coding in real time for android app.
How can I fix this?
Looks like the terminal output gives you several steps to do/check.
Make sure you have properly set up your android environment. Use this link to do so. You can use Expo-Cli or React-Native-Cli.
SDK location not found. This could be an off-shoot error of not properly doing step 1. However, to cover all of your bases, ensure you have properly set up your Android Emulator. This doc is a great walkthrough.
Once your Android studio and AVD Manager is properly set up, and your development environment is properly set, you should have no issues!
Please let me know if doing the above to steps did or did not solve your errors.
If you follow the steps, https://reactnative.dev/docs/environment-setup and https://developer.android.com/studio/run/emulator there will be no problem.
As a React Native fan on Windows 10, I'd like to mention just few points you need to check.
First, please check following user variables in Environment Variables ( You can see it from System Properties).
adb="C:\Users{username}\AppData\Local\Android\Sdk\platform-tools"
ANDROID_HOME="C:\Users{username}\AppData\Local\Android\Sdk"
JAVA_HOME="C:\Program Files\OpenJDK\openjdk-11.0.15_10"
Path: check if contains {ANDROID_HOME}\platform-tools
Eg:"C:\Users{username}\AppData\Local\Android\Sdk\platform-tools"
Second, if you are using Android Sdk emulator, please make sure that it configured correctly in emulator list in Android Studio.
For an instance, I created a android emulator using android sdk-29 and you can check the followings.
Third, I recommend you, deploy first app on emulator in Android Studio.
Because we need to download gradle zip file and others, it's essential to run your first android app in Android Studio.
When you confirmed your first android app(Deploy empty project app is also okay), you can run your React Native App by Expo-cli or react-native-cli.
I recently added the dev-client in my Expo (Bare Workflow) React Native App. The deep linking configuration was working fine earlier with my scheme as:
scheme://mobile-prefix/product/10
In the local environment, I tried using the local development Deep-link as follows:
scheme://expo-development-client/?url=http://192.168.5.80:8081
This opened the app ^. This was according to the documentation: https://docs.expo.dev/development/development-workflows/#deep-linking-urls
But it still isn't clear how do I open the deep link say to a particular product which was earlier: mobile-prefix/product/10.
The way to make it work was:
Create development build.
Then use the local scheme URI, like below. See screenshot for reference
scheme://192.168.5.80:8081/mobile-prefix/product/10
So the above URI works ^
where mobile-prefix/product/10 is the one configured on React Native App itself.
I was using your above answer with React Navigation which didn't work.
You might not need the IP address. Just your-scheme-here://mobile-prefix/product/10 will work.
I have made android emulator and other things properly but nothing really works for me. It says,
Couldn't start project on Android: The system cannot find the path specified
I am using windows 10 as operating system.
I also had the same problem.
check your ANDROID_HOME variable in advance system setting.
It must point to your SDK: C:\Users\$USER_NAME\AppData\Local\Android\Sdk
Everytime I try to launch a react native project I got this error
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
I reinstalled nodejs, python and jdk using choco as suggested on official docs. Every single packages is installed as well as sdk 23.0.1
I can see my virtual device if I run adb devices USB debugging is activated and it's running android 6.
I setup ANDROID_HOME path in environment variables, I'm using same sdk path as you can see in the picture. I also setup another one for JAVA_HOME and Python.
My PATH looks like this:
I just don't understand what I'm supposed to do. I'm using a surface pro 4, Windows 10. I can run projects using expo. I literally tried everything, restart computer, start cmd using admin, create new virtual devices, uninstall everything and start from scratch, it just don't work.
You have pointed out two issues; first, make sure you have an android emulator running. To do that, you run adb devices and you say you can see you device.
The other issue is with the environment. To make sure your environment is setup properly for android, go to the root of your react-native project. Open the android project using android studio.
All errors with your environment will show up, use the automatic fixes provided by android studio. Clean the project in android studio. Close studio and go back to command line, run react-native run-android
Everything should work now.
When doing react-native start it will intentionally hang at "Loading dependency graph" (its not really hanging, its just waiting to receive build/bundle signals). This is correct. You have to open a second terminal then do react-native run-android.
If you get errors, then cd android in your project folder then run ./gradlew clean, then after that do another react-native start then react-native run-android.
Solution is to delete all java JDK and reinstall v8 / change JAVA_HOME to the new path.
Also changing gradle-wrapper.propertiesfile for each project you want to run
# update gradle to latest version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
Sometimes it dosen't compile with v4 so I have to use v3. React native is definitely confusing.
after install dan update environment JDK now I can install app on my device
I m having a problem when I try to run my react-native application in my Android Device. The device is connected even when I make sure that it is.
adb devices
List of devices attached
HMNBBCE6A2826109 device
Device: Huawei Y2
Android Version: 5.1
Debug mode: enbaled
the server is running.
When i run
react-native run-android
I get this error
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
I had the same problem with my linux laptop.
I ran this inside my app root folder and worked:
chmod 755 android/gradlew
You have to give permission on the android/gradlew.
I found the answer on this github issue
And you must also do this:
Click here to see the all article on the react-native docs page (the place where i get this information).
Configure the ANDROID_HOME environment variable
The React Native tools require some environment variables to be set up in order to build apps with native code.
Add the following lines to your $HOME/.bash_profile config file:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
.bash_profile is specific to bash. If you're using another shell, you will need to edit the appropriate shell-specific config file.
npx #react-native-community/cli doctor
This command checks your environment and displays a report of the status of react-native installation. Check the output carefully for other software you might need to install
I've been struggling with this for a while and in my case (using Windows 10) the solution was to install Java JRE and JDK even though I was already set up with Android Studio.
The problem got clearer when I created a new empty project with create-react-native-app Example and ran it with react-native run-android. The error then complained about JAVA_HOME variable.
Another good tip is to open up your project (located under "android"-folder in your react native project) in Android Studio and see if it compiles.
Good luck!
Try the command.
adb devices
See if there is any devices listed.
If so check the local.properties file inside android folder and check the sdk defined is correct.
if there is no local.properties files. add a new file named local.properties with the following content
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu May 25 18:29:08 IST 2017
sdk.dir=path to sdk
This command will also help
adb reverse tcp:8081 tcp:8081