android - 创建签名的 apk 时出现此错误

标签 android

错误: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 {
....
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
.....}

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

关于android - 创建签名的 apk 时出现此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50890033/

相关文章:

java - 在 Docker 容器内运行时偶尔会出现 Robolectric 测试失败

android - 如何修复 Koin lib 中的 "No compatible definition found for type ' 上下文?

android - 使用 2.0 API 的 Android 上的 Couchdb

android - 是否可以让应用程序通过自己的 wifi 与 PC 交互?

android - 如何防止 iOS 和 Android 上基于 flutter 的应用程序进行屏幕录制?

android - "cordova run android"不反射(reflect)设备/模拟器上的变化

android - 如何使用 android 中的数据绑定(bind)从 EditText 获取按钮单击的值?

Android Studio - 值必须≥ 0

android - 开启硬件加速时的模糊效果

android - 选择项目后如何关闭抽屉导航?