React-native: react native run android failing

Created on 1 Sep 2017  路  14Comments  路  Source: facebook/react-native

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

  1. react-native -v:0.47.2
  2. node -v:7.6.0
  3. npm -v:5.3.0
  4. yarn --version:0.27.5

Then, specify:

  • Build tools:Atom editor with react-native run-android

Steps to Reproduce

(Write your steps here:)

1.react-native init AwesomeProject
2.react-native run-android

Expected Behavior

I follow all instructions from react native android guide page, however when I create project with react-cli and run react-native run-android and android emulator was already opened

Actual Behavior

here is the error I face with:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'test'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve org.apache.commons:commons-compress:1.8.1.
     Required by:
         :test:unspecified > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 >

com.android.tools:sdklib:25.2.3
:test:unspecified > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 >
com.android.tools:sdklib:25.2.3 > com.android.tools:repository:25.2.3

Could not resolve org.apache.commons:commons-compress:1.8.1.
Could not get resource 'https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom'.
Could not HEAD 'https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom'.
Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection timed out
(Connection timed out)

* 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 mins 16.65 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 search a full day to figure out what causing this problem on google but nothing found useful.
Here is some info:

$ java -version

openjdk version "1.8.0_131"   
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

$ android list avd

Available Android Virtual Devices:
    Name: Pixel_API_25
  Device: pixel (Google)
    Path: /home/danial/.android/avd/Pixel_API_25.avd
  Target: Google APIs (Google Inc.)
          Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86_64
    Skin: pixel
  Sdcard: 100M

$ echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/danial/Android/Sdk/tools:/home/danial/Android/Sdk/platform-tools:/home/danial/Android/Sdk/tools/bin

So all things setup correctly I really don't know where is the problem.
I asked my question in stack overflow and got one answer however that was came with some error too
Here is the answer

Looks like your project could not get dependencies from jcenter. Try to add repos to your build.gradle file.

      repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        jcenter()
      }

Put code above in the body of buildscript {...}.
**Answer Error Log :**

[Fatal Error] apache-13.pom:1:44: Content is not allowed in prolog.
[Fatal Error] apache-13.pom:1:44: Content is not allowed in prolog.
[Fatal Error] apache-13.pom:1:44: Content is not allowed in prolog.
[Fatal Error] apache-13.pom:1:44: Content is not allowed in prolog.
[Fatal Error] apache-13.pom:1:44: Content is not allowed in prolog.
[Fatal Error] apache-13.pom:1:44: Content is not allowed in prolog.
[Fatal Error] apache-13.pom:1:44: Content is not allowed in prolog.
[Fatal Error] apache-13.pom:1:44: Content is not allowed in prolog.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'test'.

> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve org.apache.commons:commons-compress:1.8.1.
     Required by:
         :test:unspecified > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 >

com.android.tools:sdklib:25.2.3
:test:unspecified > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 >
com.android.tools:sdklib:25.2.3 > com.android.tools:repository:25.2.3

Could not resolve org.apache.commons:commons-compress:1.8.1.
Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom
Could not resolve org.apache.commons:commons-parent:33.
Could not resolve org.apache.commons:commons-parent:33.
Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-parent/33/commons-parent-33.pom
Could not resolve org.apache:apache:13.
Could not resolve org.apache:apache:13.
Could not parse POM https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom
Content is not allowed in prolog.
Could not resolve org.apache:apache:13.
Could not parse POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom
Content is not allowed in prolog.
Could not resolve org.apache.commons:commons-parent:33.
Could not parse POM https://repo1.maven.org/maven2/org/apache/commons/commons-parent/33/commons-parent-33.pom
Could not resolve org.apache:apache:13.
Could not resolve org.apache:apache:13.
Could not parse POM https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom
Content is not allowed in prolog.
Could not resolve org.apache:apache:13.
Could not parse POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom
Content is not allowed in prolog.
Could not resolve org.apache.commons:commons-compress:1.8.1.
Could not parse POM https://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom
Could not resolve org.apache.commons:commons-parent:33.
Could not resolve org.apache.commons:commons-parent:33.
Could not parse POM https://jcenter.bintray.com/org/apache/commons/commons-parent/33/commons-parent-33.pom
Could not resolve org.apache:apache:13.
Could not resolve org.apache:apache:13.
Could not parse POM https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom
Content is not allowed in prolog.
Could not resolve org.apache:apache:13.
Could not parse POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom
Content is not allowed in prolog.
Could not resolve org.apache.commons:commons-parent:33.
Could not parse POM https://repo1.maven.org/maven2/org/apache/commons/commons-parent/33/commons-parent-33.pom
Could not resolve org.apache:apache:13.
Could not resolve org.apache:apache:13.
Could not parse POM https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom
Content is not allowed in prolog.
Could not resolve org.apache:apache:13.
Could not parse POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom
Content is not allowed in prolog.
Still I can't run a simple react native project from scratch


screenshot from 2017-09-02 00-13-06

Android Ran Commands Locked PR Submitted

Most helpful comment

I was able to get past this by adding google() to build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

All 14 comments

+1

I really don't understand why I can't run a simple react native app please react native team help me figure out this problem

I test my problem with pure android project with android studio when I run project it will install app on emulator and run it perfectly however I read https://developer.android.com/studio/build/building-cmdline.html#RunningOnEmulator page about running android project from command line but when I run gradlew installDebug on command line I face same error so the real question is how android studio build project and run it on emulator and I can't do it with command line ?

same issue.. any updates?

same issue

I was able to get past this by adding google() to build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

@tslater thanks, adding google() to the dependencies worked for me as well.

same issue for a long time.

Note that the workaround requires Gradle 3, which we are not using on this repo just yet.

same issue :'(

Is this still an issue? We just landed a change that's similar to one of the proposed fixes.

yup still an issue, though using google repo fixes if for time being

@hramos we can close this

gradle 3 on react-native core will improve and fix more of this issues

We're not using Gradle 3 just yet. We can close this then.

Was this page helpful?
0 / 5 - 0 ratings