how to fix aapt2 error in android Studio 4.1.1?

yas*_*ash 5 android maven kotlin android-studio android-gradle-plugin

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


Run Code Online (Sandbox Code Playgroud)

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 ;(

小智 1

我有类似的问题。这为我解决了这个问题,但我不知道为什么。在我的项目 build.gradle 下,我将依赖项中的类路径更改为较低版本。我将其设置为 4.1.1,但将其更改为 3.1.4。然后我单击“立即同步”。

我仍然无法让我的模拟器运行,但这消除了错误。

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