android - 创建签名的 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 {
....
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
.....}
添加以上两行,生成签名的 APK 并在构建发布 APK 时消除 AAPT2 错误。
推荐阅读
- sql - 消息 240,锚点和列中的递归部分之间的类型不匹配
- java - 为什么我编码错误,geotools create shapefile chinese setAttribute error
- kotlin - 通过 vert.x 发送文件作为响应的表达式的名称是什么
- python - 如何消除导入文本的一部分
- reactjs - 导入默认导出未定义
- symfony - Symfony 4登录表单:认证成功,但重定向后认证立即丢失
- .net - 安装 Windows 服务时 Topshelf 抛出错误
- c++ - 为什么擦除命令会结束我的 while 循环?
- installation - 黑板安装
- python - AttributeError:“NoneType”对象没有属性“find_all”?