Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1)

爱⌒轻易说出口 提交于 2019-11-29 16:45:06

This is due you didn’t put google() as the first repo. The order of google() matters. So just add it above jcenter() will solve your problem.

See https://stackoverflow.com/a/51151050/8034839

Note that this change should be in your TOP level build.gradle file. E.g.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google() // first one
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google() // first one
        jcenter()
    }
}

Note:

Since Android Gradle Plugin (AGP) version 3.0.0 (Gradle version 4.1+), Google introduced its own Google's Maven repository google(), most of the dependencies were moved to there. So, if you are using the AGP 3.0+, you should refer to this NEW repo firstly.

And here is some explanation about different gradle versions: What is real Android Studio Gradle Version?

Thanks for @HedeH, who linked me into his answer here, saying:

Try moving the google() method (In all .gradle files) to the top of its execution block.

I did see that answer before while searching for the issue, but i missed that it must be changed "In all .gradle files".

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