首页 > 解决方案 > 创建签名的 apk 时出现此错误

问题描述

错误:java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2 错误:查看日志了解详细信息

我的 build.gradle(app) 文件是:

`apply plugin: 'com.android.application'

   android {
buildToolsVersion '27.0.3'
compileSdkVersion 27
defaultConfig {
    applicationId "newsall1.shiva.newsall1"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
  }

   dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-core:16.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- 
 core:3.0.2'
  }

  apply plugin: 'com.google.gms.google-services'`

标签: android

解决方案


android {
....
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
.....}

添加以上两行,生成签名的 APK 并在构建发布 APK 时消除 AAPT2 错误。


推荐阅读