一直以来,我的构建过程没有任何问题。我正在使用最新的build.gradle
。我正在使用Android Studio 3.1.3。
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://jitpack.io"
}
}
}
但是,当我构建发行版APK时,遇到了以前从未遇到过的以下问题:Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum
这是我的应用程序的
build.gradle
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt'
lintOptions {
disable 'MissingTranslation'
}
}
}
我怀疑
getDefaultProguardFile('proguard-android.txt')
的内容没有被提取。因此,如果我手动将
C:\Users\yccheok\AppData\Local\Android\Sdk\tools\proguard\proguard-android.txt
的内容复制到我的项目proguard-project.txt
中。该问题将解决。我可以知道为什么会这样吗?我所做的唯一更改是介绍
def lifecycle_version = "1.1.1"
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
// alternately - if using Java8, use the following instead of compiler
implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
在
build.gradle
中。但是,我不确定这与我的保障规则有何关系。
最佳答案
根据Android Documentation,默认的proguard文件将复制到目录project-dir/build/intermediates/proguard-files/
中。
检查此目录是否存在。否则,您可能没有创建权限。这可能会导致问题。
关于android - 为什么构建过程会忽略proguardFiles getDefaultProguardFile ('proguard-android.txt'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51693786/