2017-08-30 122 views
5

我按照所有說明從反應原生的Android指南頁面,但是當我創建項目,反應-CLI和運行react-native run-android我'得到了一些錯誤:反應原生Android的運行失敗

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

無法解析org.apache.commons:commons-compress:1.8.1。 無法獲取資源'https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom'。 不能HEAD'https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom'。 連接到jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188]失敗:連接超時 (連接超時)

* 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 

我搜索了一整天圖谷歌什麼原因導致這個問題,但沒有發現有用的。 下面是一些信息:

$ Java的版本

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) 

$安卓列表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 

$回聲$ 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

因此,所有東西安裝正確,我真的不知道問題在哪裏。

**First Answer Error Again:** 

[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 :測試:未指定> com.android.tools.build:gradle:2.2.3> com.android.tools.build:gradle-芯: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

無法解析org.apache.commons:commons-compress:1.8.1。 無法解析POM https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom 無法解析org.apache.commons:commons-parent:33。 無法解析org.apache.commons:commons-parent:33。 無法解析POM https://jcenter.bintray.com/org/apache/commons/commons-parent/33/commons-parent-33.pom 無法解析org.apache:apache:13。 無法解析org.apache:apache:13。 無法解析POM https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom 內容不允許在序言中。 無法解析org.apache:apache:13。 無法解析POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom 內容在序言中是不允許的。 無法解析org.apache.commons:commons-parent:33。 無法解析POM https://repo1.maven.org/maven2/org/apache/commons/commons-parent/33/commons-parent-33.pom 無法解析org.apache:apache:13。 無法解析org.apache:apache:13。 無法解析POM https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom 內容不允許在序言中。 無法解析org.apache:apache:13。 無法解析POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom 內容在序言中是不允許的。 無法解析org.apache.commons:commons-compress:1.8.1。 無法解析POM https://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom 無法解析org.apache.commons:commons-parent:33。 無法解析org.apache.commons:commons-parent:33。 無法解析POM https://jcenter.bintray.com/org/apache/commons/commons-parent/33/commons-parent-33.pom 無法解析org.apache:apache:13。 無法解析org.apache:apache:13。 無法解析POM https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom 內容不允許在序言中。 無法解析org.apache:apache:13。 無法解析POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom 內容在序言中是不允許的。 無法解析org.apache.commons:commons-parent:33。 無法解析POM https://repo1.maven.org/maven2/org/apache/commons/commons-parent/33/commons-parent-33.pom 無法解析org.apache:apache:13。 無法解析org.apache:apache:13。 無法解析POM https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom 內容不允許在序言中。 無法解析org.apache:apache:13。 無法解析POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom 內容在序言中是不允許的。

+0

您使用的是哪個操作系統? – wlisrausr

+0

@wlisrausr Ubuntu 16.04 LTS –

+0

你試過這個嗎? https://stackoverflow.com/questions/25994163/could-not-resolve-all-dependencies-for-configuration-classpath – wlisrausr

回答

1

看起來像你的項目無法從jcenter得到的依賴。嘗試將回購添加到您的build.gradle文件。

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

把上面的代碼放在buildscript {...}的主體中。

+0

我更新了我的問題你的解決方案也有一些錯誤 –

1

請嘗試從您的根目錄下面。 製作資產文件夾

/android/app/src/main/ 

cd android 

./gradlew clean 

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ 

react-native run-android