yasin naqash
yasin naqash

Reputation: 51

how to fix aapt2 error in android Studio 4.1.1?

few days ago i deleted the whole gradle file and installed it again manually introduced its path to android studio 4.1.1 and created a project to test

fortunately gradle worked fine but when i tried to run app on emulator a red goddamn error appears that doesn't let me sleep for 3 days

Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
   > Could not find aapt2-4.1.1-6503028-linux.jar (com.android.tools.build:aapt2:4.1.1-6503028).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.1.1-6503028/aapt2-4.1.1-6503028-linux.jar

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html


i read the documentation and i guess that was outdated or just couldn't solve my problem cause i declared repository and nothing made a difference.

every solution i found belongs to 2 or 3 years ago and most of em say the same

add google() to your repositories in build.gradle

and they were right

that should made the problem solved but in 3 years ago.

now by default android studio has google() in repositories and still i see the goddamn red error on my screen

in error obviously points to missing a file named aapt2-4.1.1-6503028-linux.jar and thanks to google ,it gives me the download link i downloaded the file but i don't know where to put it.

as the error says ,

Could not resolve all files for configuration ':app:_internal_aapt2_binary'.

so anybody knows a path for this file or what ever it is ?!

make an old noob programmer HAPPY ;(

Upvotes: 5

Views: 4204

Answers (3)

Shamshun
Shamshun

Reputation: 482

After many hours messing with Gradle repository config, etc. This solved the problem:

In Android Studio, go to {File} menu > {Invalidate Caches and Restart},

Then Sync your gradle/project.

It seems that some older files/packages are becoming idiotic when you update your IDE.

p.s I also did {Help} > {Check for IDE updates} and there were updates for Emulator and stuff. It still didn't work, until i used the "Invalidate Caches" option.

Upvotes: 1

Jaaveeth
Jaaveeth

Reputation: 21

Hi sorry for the late answer ,may be this will use to others Add Maven to your project build.gradle app it will solve

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

Upvotes: 2

RobPesc
RobPesc

Reputation: 45

I had a similar issue. This solved it for me, but I don't know why. Under my Project build.gradle I changed the classpath in my dependencies to a lower version. I had it set as 4.1.1 but changed it to 3.1.4. I then clicked Sync Now.

I still cannot get my emulator to run, but this got rid of the error.

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tolls.build.gradle:3.1.4" //was 4.1.1
    }
}

Upvotes: 1

Related Questions