I am writing a React Native App for Android. I initialized the project with the react-native-cli. When I try to run it on Android, I get the following error:
$ react-native run-android
Scanning folders for symlinks in /path/to/myreactnativeproject/node_modules (6ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'myreactnativeproject'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
:myreactnativeproject:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 11.226 secs
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 am using Ubuntu 16.04 and I installed Android Studio 3.0.1. What is the reason for the error?
Edit: When I run it with stacktrace, info and debug, I get the following output:
I can't post the output here, because it is to long: pastebin
I fixed it by adding this to .bashrc:
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
export PATH=$JAVA_HOME/bin:$PATH
Related
This question already has answers here:
react-native :app:installDebug FAILED
(35 answers)
Closed 9 days ago.
Hi i got this error when i try to run react app on my real android device via : react-native run-android
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to install all
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Try these steps.
Delete node modules folder in your project.
Delete build folder in android/build
Close all running terminals.
Make sure you have installed adb drivers in your environment. If not install adb drivers. (For macOS / For Windows)
Open new terminal window and in your project folder run npm install to re-install node modules.
Finally run your app using react-native run-android
If you are using Android Studio, make sure you run the emulator before running the commands and the emulator API level matches the targetSdk (build.gradle).
I create the simple React Native Project.
Step 1.
C:>react-native init AwesomeProject
Step 2.
C:>cd AwesomeProject
Step 3.
C:>react-native run-android
After that I faced the following error.
C:\Users\Smith\AwesomeProject>react-native run-android
Scanning 575 folders for symlinks in C:\Users\Smith\AwesomeProject\node_modul
es (13ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat install
Debug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory 'C:\Users\Smith\AwesomeProject\android\C:UsersSmithApp
DataLocalAndroidsdk' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 4.774 secs
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
Thanks!!
Android sdk path in your enviroment is not correct.
I was trying to run an android project with this command:
react-native run-android
but it doesn't build anything and print this msg:
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not download javax.inject.jar (javax.inject:javax.inject:1)
> Could not get resource 'https://jcenter.bintray.com/javax/inject/javax.inject/1/javax.inject-1.jar'.
> Could not GET 'https://jcenter.bintray.com/javax/inject/javax.inject/1/javax.inject-1.jar'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed
t: connect
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log outpu
BUILD FAILED
Total time: 2 mins 17.303 secs
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
how can I fix it?
as you can see, you need to run your android simulator first or connect to a device.
so in your terminal
type:
android avd
then create a device if you dont have one, then start it.
If the simulator has run, then you can start building by typing
react-native run-android
I am new to ionic. I have developed sample application ionic.
When I try to execute below command it gives gradle error.
$ ionic build android
Below is the build error:
Error: /home/myapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred starting process 'Gradle build daemon'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Gradle version is 3.3
Android SDK and Android Studio located in /usr/local/ folder
You will either have to move it to your home directory (that involves reinstall).
Or run ionic build commands with sudo
sudo ionic build android
You could technically change permissions of the specific sdk and studio folders but it is not advisable especially in /usr directory.
I am using React Native 0.26 and trying to play around with Google Plus Sign in from the below npm for Android application.
npm install react-native-google-signin --save
I am using command-line(react-native run-android) to build debug apks directly on my devices.
Followed all the installation steps very carefully. By default, my builds are working only on Build tools version 1.2.3 on build.gradle(/android/) and it used to work for other projects but I am having the below error in this project because I had to include the below line in build.gradle file,
classpath 'com.google.gms:google-services:2.1.0' // <--- add this
and when I add this, I also have to modify the distributionUrl to https\://services.gradle.org/distributions/gradle-2.13-all.zip on android/gradle/wrapper/gradle-wrapper.properties
After doing all the modifications when I tried to run the build command, it never installs the updated apk on the device and it is stuck at 99% progress.
Below is the detailed error,
Installing APK 'app-debug.apk' on 'Micromax Q372 - 5.0' for app:debug
08:26:35 E/1526411097: Error while uploading app-debug.apk : Unknown failure ([CDS]close[0])
Unable to install /home/sid/react/gplus/android/app/build/outputs/apk/app-debug.apk
com.android.ddmlib.InstallException: Failed to install all
at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:91)
......
:app:installDebug FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:installDebug'.
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to install all
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I had the same issue trying to install an APK on a specific device.
To solve I listed all the connected devices with adb devices and I identified the right one, then I ran run-android specifying the device ID:
react-native run-android --deviceId MY-DEVICE-ID