Could not find com.android.tools.build:aapt2:3.2.0

主宰稳场 提交于 2019-11-26 18:51:15
Izabela Orlowska

Beginning with Android Studio 3.2 Canary 11, the source for AAPT2 (Android Asset Packaging Tool 2) is Google's Maven repository.

To use AAPT2, make sure that you have a google() dependency in your build.gradle file, as shown here:

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

The new version of AAPT2 fixes many issues, including improved handling of non-ASCII characters on Windows.

Adding the repositories in the buildscript is not sufficient, you need to add it also in allprojects.

Source: https://developer.android.com/studio/releases/#aapt2_gmaven

Are you opening a very old project? If so, make sure your app's build.gradle has:

apply plugin: 'com.android.application'

repositories {
    google()
    jcenter()
} 

(That solved it for me anyways)

fMadTech

Just add google() on your buidscript and allprojects then rebuild the project.

buildscript {
    repositories {
        google() // `enter code here`
    }
 }

allprojects {
    repositories {
        google() // `<-- here`
    }
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        google()  //导入旧版本项目时,一般来说该处依赖会在更改classpath中gradle版本是自动添加
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
       /*
        解决报错:Could not find com.android.tools.build:aapt2:3.3.0-5013011.
        Beginning with Android Studio 3.2 Canary 11, the source for AAPT2 (Android Asset Packaging Tool 2) is Google's Maven repository.
        To use AAPT2, make sure that you have a google() dependency in your build.gradle file, as shown here:
        */
        google() //但是此处不会,需要自主添加
        jcenter()
    }
}

if google() not fixied then File -> Setting -> Build, Execution, Deployment -> Gradle

Then Uncheck Ofline Work, Done.

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