1

[x] submitting bug

[x] Android platform react-native

[x] ubuntu 16.04 LTS

I am having issue in creating build by command react-native run-android

Here i am pasted error:

$ react-native run-android Scanning folders for symlinks in /home/pct3/webroot/Hello/node_modules (39ms) JS server already running. Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

BUILD FAILED in 12s 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/getting-started.html

Your help will save my day, if you need any extra information let me know.

Github link: Issue

5
  • "Make sure you have an Android emulator running or a device connected and have set up your Android development environment: facebook.github.io/react-native/docs/getting-started.html" <-- did you do this? Commented Feb 14, 2018 at 8:09
  • a Gradle issue, you can delete Gradle build folder android/.gradle and rebuild project. Commented Feb 14, 2018 at 8:45
  • @IshitaSinha yes i have setup Android development, i am using genemotion as emulator, adb devices command also display that emulator as running. Commented Feb 14, 2018 at 9:01
  • One thing i found weired that, app is runnig when run from android studio, but error of gradle when typing command react-native run-android Commented Feb 14, 2018 at 10:10
  • @AndroidTeam Tried but does not solving error Commented Feb 14, 2018 at 10:24

3 Answers 3

2

a fast and easy solution to this issue is as following

1- open android/build.gradle 2-replace the gradle version with an older one for example 3.0.1

example of how it should look

classpath("com.android.tools.build:gradle:3.0.1")

and boom no more issues

Sign up to request clarification or add additional context in comments.

Comments

0

Delete or rename the android folder and run react-native upgrade command.

2 Comments

That's a good solution, but it gives another error, error of gradle gone and new error is: ` > Could not resolve all dependencies for configuration ':classpath'. > Could not download protobuf-java.jar (com.google.protobuf:protobuf-java:2.5.0) > Could not get resource 'jcenter.bintray.com/com/google/protobuf/protobuf-java/2.5.0/…'. > Could not GET 'jcenter.bintray.com/com/google/protobuf/protobuf-java/2.5.0/…'. > sun.security.validator.ValidatorException: No trusted certificate found `
Then the error belongs to your java gradle installation in your system.The error does not belongs to react native.Update or reinstall android sdk setup.
0

Run npm install

Change your build.gradle so it follows this format:

You can see all available artifacts at Google's Maven repository index (see below for programmatic access). To add one of these libraries to your build, include Google's Maven repository in your top-level build.gradle file:

allprojects {
  repositories {
      google()

    // If you're using a version of Gradle lower than 4.1, you must instead use:
    // maven {
    //     url 'https://maven.google.com'
    // }
    // An alternative URL is 'https://dl.google.com/dl/android/maven2/'
 }
}

More info here https://developer.android.com/studio/build/dependencies

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.