"AAPT2 process unexpectedly exit. Error output:" 正在测试中

"AAPT2 process unexpectedly exit. Error output:" in testing

我的应用程序在构建时遇到问题,因为当我尝试构建它时,它弹出并显示如下屏幕所示的错误。我试过将以下内容放入 gradle.properties 文件中:

AAPT2.enabled=false
android.enableAapt2=false

但是这些在 3.3 中都不起作用,因为它说禁用 aapt2 已被弃用,无论如何都会启用,从而引发相同的错误。我最好寻找长期解决方案,但我们将不胜感激任何建议。提前致谢。

这就是我自己解决这个问题的方法(多亏了这个Youtube video) 在 Android 工作室的项目级别 build.gradle 文件中:像这样升级 gradle 构建工具:

旧:

    dependencies {
     classpath 'com.android.tools.build:gradle:3.3.2'
    
}

新:

    dependencies {

    classpath 'com.android.tools.build:gradle:3.4.0'
    
}

鉴于2021年1月的现状,可以参考以下版本。在您的项目 build.gradle 文件中 将依赖项降级到 gradle 4.0.2,如下所示

dependencies {

        // for AAPT2 ERROR RESOLUTION
        classpath "com.android.tools.build:gradle:4.0.2"

    }

我也遇到了这个错误。尝试更改 Gradle 文件

中的类路径
dependencies {
    ....
    classpath 'com.android.tools.build:gradle:4.0.0'
}
   I'm running my existing application on another system it shows this error
     aapt2 process unexpectedly exit. error output:

    here what i did 
   in android>build.gradel not in android>app>build.gradel
   change from   dependencies {
    classpath("com.android.tools.build:gradle:4.1.0")
    classpath('com.google.gms:google-services:4.3.3')
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
   }
    change to 
     dependencies {
    classpath("com.android.tools.build:gradle:3.6.4")
    classpath('com.google.gms:google-services:4.3.4')
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
     }

如果上述方法不起作用,请禁用防病毒软件。 Smadav 挡住了我的火箭发射