【问题标题】:Could not find aapt2-proto.jar找不到 aapt2-proto.jar
【发布时间】:2019-03-27 10:17:38
【问题描述】:

看到这个link(我怀疑)有 POM 文件但没有 jar。

重要提示:

  • 我目前正在使用 latest 版本的 react native ... v0.57.3 以及 latest 版本的 react-native-cli ... v2.0.1。
  • 我的计算机中安装了 Java 11。
  • 我此时正在使用latest gradle release ... v4.10.2
  • 我正在使用 Mac OSX Mojave

分发网址是:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

这是错误

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'AwesomePlacesApp'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/aapt2-proto/0.3.1/aapt2-proto-0.3.1.jar

【问题讨论】:

  • 您在项目中尝试过任何升级吗?
  • 哪种类型的升级@KosalramRamaKrishnan ? ... FWIW,我刚刚编辑了我正在使用最新版本的 react native 和 react native cli 的评论 ...它是一个新项目 ...
  • 遇到了同样的错误。如果你点击链接,你会得到一个 404。我想我们必须等到 jcenter 解决它。
  • @Harry 我怀疑您使用的 SDK 版本可能不兼容。缺少 jar 文件通常会发生很多。只需在 Android Studio 中打开您的项目,它就会根据您在项目中使用的新版本重新构建您的项目。如果问题仍然存在,请告诉我。
  • 也许这会有所帮助:stackoverflow.com/a/52944600/4255978

标签: android android-studio react-native jcenter aapt2


【解决方案1】:

Google 的 maven 存储库中似乎提供了 AAPT2(Android 资产打包工具 2)。

您需要在 build.gradle 文件的存储库下包含 google(),如下所示:

buildscript {
  repositories {
      google() // here
      jcenter()
  }
  dependencies {
      classpath 'com.android.tools.build:gradle:3.2.0-alpha12'
  }
} 
allprojects {
  repositories {
      google() // and here
      jcenter()
}

查看link 了解更多详情。

注意:顺序也很重要,如果 jcenter() 高于 google() 则失败。

【讨论】:

  • 请注意,顺序很重要,如果 jcenter() 高于 google() 它对我来说失败了。
  • 如果它不适合您,请确保更改这两个位置。也接受@fejd 的建议。
  • 确实,将 google() 作为存储库中的第一项
  • @PedroPauloAmorim 它也不适合我。你还有其他答案吗?
【解决方案2】:

这似乎是一个 jCenter 问题。在问题解决之前,您可以在根 build.gradle 文件中临时将 Android Gradle 插件版本更改为 3.1.0

dependencies { classpath 'com.android.tools.build:gradle:3.1.0' // other imports here... }

【讨论】:

    【解决方案3】:

    我改变了这个文件的顺序:android/build.gradle

    对我来说正在处理这个订单:

    buildscript {
        ext {
            buildToolsVersion = "27.0.3"
            minSdkVersion = 16
            compileSdkVersion = 27
            targetSdkVersion = 26
            supportLibVersion = "27.1.1"
        }
        repositories {
            google()        
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
        }
    }
    
    allprojects {
        repositories {
            mavenLocal()
            google()
            jcenter()
            maven {
              url "$rootDir/../node_modules/react-native/android"
            }        
        }
    }
    
    task wrapper(type: Wrapper) {
        gradleVersion = '4.4'
        distributionUrl = distributionUrl.replace("bin", "all")
    }
    

    【讨论】:

      【解决方案4】:

      这个问题的答案在 build.gradle 中更改 google() 的位置并将其放在第一位: 这是以前的样子,如果你没有 google() 将它添加为 buildscript 中的第一个:

      buildscript {
             repositories {
                        jcenter()
                        google()
      }
      

      改成,

      buildscript {
             repositories {
                     google()
                     jcenter()
      }
      

      【讨论】:

        【解决方案5】:

        项目->打开模块设置->“项目结构-项目”

        检查您的 Android 插件存储库默认库存储库

        注意:google(), jcenter - 它在我的项目中的默认值。

        【讨论】:

          【解决方案6】:

          您必须将 google() 添加到 build.gradle 文件中的存储库并将其放在 第一个位置

          ...
          repositories {
              google()        
              jcenter()
          }
          ...
          

          就我而言,问题在于存储库顺序。

          【讨论】:

            【解决方案7】:

            对我来说,在 gradle 更新后解决了问题,请注意,即使将 google() 添加到存储库,我也遇到了问题

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2019-03-27
              • 2019-03-27
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2018-11-09
              • 1970-01-01
              相关资源
              最近更新 更多