4
votes

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

4

4 Answers

13
votes

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).

  1. 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.

3
votes
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

0
votes

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!

-1
votes

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