React-Native run android

Asked

Viewed 1,329 times

2

Hello guys I’m starting a project with React-On but I’m having serious problems so far in trying to run the code in the emulator of android studio, so far I have not made changes in the project files, are the way they were installed. If anyone can help me I’ll be grateful, follow the mistake :

Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/eliascmendhes/my_pet/android/local.properties'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 28s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/eliascmendhes/my_pet/android/local.properties'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 28s

    at checkExecSyncError (child_process.js:601:13)
    at execFileSync (child_process.js:621:13)
    at runOnAllDevices (/home/eliascmendhes/my_pet/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
    at buildAndRun (/home/eliascmendhes/my_pet/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
    at then.result (/home/eliascmendhes/my_pet/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

4 answers

1

If you are using the zsh terminal. Access the file that is in your user folder, its name is .zshrc. Go to the end of that file and add the following code:

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

If you have the default Ubuntu terminal, bash, you can access the file . bashrc in the same folder, and add the same code above.

Once done, just close and open the terminal again, and it will work.

1

By error the system is not finding android SDK containing emulator Devices. You must set the environment variable so that React-Nenable finds the emulator correctly.

Do so. Click the windows search or hit the Win key on your keyboard. Search Environment Sweeps. You should see the following screen:

inserir a descrição da imagem aqui

Click this button for environment variables and below the list of variables, click new. On behalf of the variable type

ANDROID_HOME

In variable value you enter the SDK folder. It changes according to the installation but is usually in

C: Users Username Appdata Local Android Sdk

and paste into this variable’s value field and save. DISCLAIMER: Username in the path is usually your computer username, and the Appdata folder is usually hidden. Then it is recommended that you enter the SDK folder manually and copy the full path.

Then just save and try to compile the project again.

  • I’m already very pleased by your help, but I use Ubuntu, and so what is ? Already obg.

1

In the official documentation is written the following for linux. Run after Android SDK is installed:

3. 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 or $HOME/.bashrc config file:

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
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.

Type source $HOME/.bash_profile to load the config into your current shell. Verify that ANDROID_HOME has been added to your path by running echo $PATH.

Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio "Preferences" dialog, under Appearance & Behavior → System Settings → Android SDK.

Link: Documentation Rect-Native

-1

So little guy, I went through the same problems a while ago. The solution I found was the following. After installing the Voce SDK you need to "warn" the native android code which SDK you should use.

  1. Create a file local.properties in android folder.
  2. In this file passes the place where the SDK is. Passes right the place, starts at the root. In my Ubuntu was like this: sdk.dir=/home/koe/Android/Sdk Use the same syntax and pass the right location.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.