反应原生 - 获取构建工具文件时出错

Posted

技术标签:

【中文标题】反应原生 - 获取构建工具文件时出错【英文标题】:react native - error while fetching build tools files 【发布时间】:2018-11-06 21:31:09 【问题描述】:

我无法使用 react-native run-android 构建我的 android 应用程序,因为我收到以下错误。昨天一切正常。你知道问题出在哪里吗?

A problem occurred configuring root project 'contacto'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find builder.jar (com.android.tools.build:builder:3.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/builder/3.1.2/builder-3.1.2.jar
   > Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
   > Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/manifest-merger/26.1.2/manifest-merger-26.1.2.jar
   > Could not find builder-test-api.jar (com.android.tools.build:builder-test-api:3.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/builder-test-api/3.1.2/builder-test-api-3.1.2.jar
   > Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.1.0).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/aapt2-proto/0.1.0/aapt2-proto-0.1.0.jar
   > Could not find builder-model.jar (com.android.tools.build:builder-model:3.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/builder-model/3.1.2/builder-model-3.1.2.jar
   > Could not find annotations.jar (com.android.tools:annotations:26.1.2).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/annotations/26.1.2/annotations-26.1.2.jar

【问题讨论】:

Could not find runtime.jar (android.arch.lifecycle:runtime:1.0.0)的可能重复 是的,就像重复问题中所述的存储库(服务器端)的问题 是的,该帖子的第一个答案对于这个错误是正确的。 也许这会有所帮助:***.com/a/52944600/4255978 【参考方案1】:

在项目的 gradle 文件中添加以下行

allprojects 
    repositories 
        .....
        ......
        maven  url 'https://maven.google.com'   //  Add this line.
        ......
     

【讨论】:

【参考方案2】:

对于那些有同样错误的人,请尝试将其添加到 App Builde.gradle :

android 
    //the rest of the code above

    lintOptions 
       disable 'MissingTranslation'
    

我遇到了同样的问题,无论出于何种原因,这对我有用。

【讨论】:

【参考方案3】:

对我有用的唯一解决方案是转到 Build --> Build Types,并将 google() 添加到两个 repos

【讨论】:

以上是关于反应原生 - 获取构建工具文件时出错的主要内容,如果未能解决你的问题,请参考以下文章

安装 json gem 时出错:“json”本机 gem 需要安装构建工具

我可以使用 JavaFX 原生构建工具拥有多个可执行文件吗?

安装导轨时出错

尝试安装本机反应时出错,运行 pod install 时无法正确构建

Wix 资源收集工具“Heat”。如何获取具有动态名称的文件,例如构建时生成的 Microsoft 运行时文件

EMFile:打开的文件太多,观看 - 构建 Release 反应原生 iOS 应用程序