react-native can't build run android correctly - android

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

Related

Execution failed for task ':app:installDebug' react native app [duplicate]

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

Dependency error in React Native for Android

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

Android React Native build fail

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.

react-native run-android Starting JS server... Building and installing the app on the device (cd android && ./gradlew installDebug

After
react-native init Project
i do :
cd Project and
react-native run-android
my version is : nodejs v6.9.5
emulateur genymotion api 23
I have this error :
Starting JS server...
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 project ':app'.
> failed to find Build Tools revision 23.0.1
* 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.309 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
Install Build Tools revision 23.0.1 on SDK

Cordova ionic application won't start on device

my case the driver is ok and the device is connected:
adb devices
List of devices attached
7F602C136346331 device
but when i execute this command:
ionic run android -l -c
i found this error :
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':CordovaLib:processDebugResources'.
java.io.IOException: Cannot run program "/home/binov1/android-sdk-linux/build-tools/23.0.1/aapt": error=2, No
such file or directory
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: 2.28 secs
/home/binov1/workElolinkMobile/ElolinkProject/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^ Error code 1 for command: /home/binov1/workElolinkMobile/ElolinkProject/platforms/android/gradlew
with args:
cdvBuildDebug,-b,/home/binov1/workElolinkMobile/ElolinkProject/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true
ERROR running one or more of the platforms: Error:
/home/binov1/workElolinkMobile/ElolinkProject/platforms/android/cordova/run:
Command failed with exit code 8 You may not have the required
environment or OS to run this project
Is a problem with the build.
Install the andoid sdk
https://developer.android.com/sdk/index.html#download
verify tools and android tools is well declared in the path
export PATH=$PATH:/path/to/tools
export PATH=$PATH:/path/to/platform-tools
update android run command
> android update sdk
and try again.

Categories

Resources