Could not find aapt2-proto.jar

让人想犯罪 __ 提交于 2019-11-30 10:50:30

It seems like AAPT2(Android Asset Packaging Tool 2) is available in Google's maven repository.

You need to include google() under repositories in build.gradle file as shown:

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

Take a look at this link for more in detail.

Note: Order also matters, if jcenter() is above google() it fails.

This seems to be a jCenter issue. Until the issue is fixed you can temporarily change Android Gradle Plugin version to 3.1.0 within root build.gradle file:


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

I changed the order of this file: android/build.gradle

For me is working with this order:

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")
}

This question's answer In build.gradle change position of google() and place it first: This is how it was before, if you don't have google() add it as the first one in the buildscript:

buildscript {
       repositories {
                  jcenter()
                  google()
}

change to,

buildscript {
       repositories {
               google()
               jcenter()
}

Project -> Open Module Setting -> "Project Structure - Project"

Check your Android Plugin Repository and Default Library Repository.

Note: google(), jcenter - its default value in my project.

You have to add google() to repositories in build.gradle file and put it at first position:

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

In my case the problem was the repository order.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!