[Fixed] : “Could not find com.android.tools.build:aapt2” Error

You import a project in the new version of Android Studio and get the following error (while running or building)

Could not find com.android.tools.build:aapt2:3.3.0-5013011.
Searched in the following locations:

Required by:
project :app

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

The solution is simple, make sure that you have a google() dependency in your build.gradle file. Simply go to your project’s build.gradle file and add the below lines:

allprojects {
repositories {
google()
jcenter()
}
}

Ensure that the google() dependency is put right on top.

Your build.gradle file should now be:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath ‘com.android.tools.build:gradle:3.3.0’
}
}

allprojects {
repositories {
google()
jcenter()
}
}

Hope this solution helped you. If it did, consider leaving us a link from your blog.

Comment Policy: Comments adding value to the article are encouraged. Relevant links will be allowed in such comments.
If you think that you have a link that adds value to this article please contact us at techie[at]techzog[dot]com for evaluation of inclusion into the article.
Comments left solely for spamming links will be deleted. Thank you for understanding.

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge

This site uses Akismet to reduce spam. Learn how your comment data is processed.