繁体   English   中英

反应本机运行android失败

[英]react native run android failing

我按照本机android指南页面的所有说明进行操作,但是当我使用react-cli创建项目并运行react-native run-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 -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

所以所有东西设置正确我真的不知道问题出在哪里。

 **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: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。 无法解析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 prolog中不允许使用内容。 无法解析org.apache:apache:13。 无法解析POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom prolog中不允许内容。 无法解析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 prolog中不允许使用内容。 无法解析org.apache:apache:13。 无法解析POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom prolog中不允许内容。 无法解析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-父: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 prolog中不允许使用内容。 无法解析org.apache:apache:13。 无法解析POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom prolog中不允许内容。 无法解析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 prolog中不允许使用内容。 无法解析org.apache:apache:13。 无法解析POM https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom prolog中不允许内容。

看起来您的项目无法从jcenter获取依赖项。 尝试将repos添加到build.gradle文件中。

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

将上面的代码放在buildscript {...}的主体中。

从根目录中尝试以下操作。 创建资产文件夹

 /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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM