为什么构建过程会忽略proguardFiles getDefaultProguardFile('proguard-android.txt') [英] Why the build process ignore proguardFiles getDefaultProguardFile('proguard-android.txt')
问题描述
一直以来,我的构建过程都没有任何问题。我正在使用最新的 build.gradle
。我正在使用Android Studio 3.1.3。
All the while, I don't have any issue with my build process. I'm using latest build.gradle
. I'm using Android Studio 3.1.3.
// 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版本APK崩溃与Java .lang.AssertionError:在java.lang.Enum中是不可能的
However, when I build a release APK, I face the following problem which I had never face before : 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
。问题将会解决。
So, if I manual copy the content of C:\Users\yccheok\AppData\Local\Android\Sdk\tools\proguard\proguard-android.txt
to my project proguard-project.txt
. The problem will resolve.
我可以知道为什么会这样吗?我所做的唯一更改是引入了
May I know why it is so? The only change I did, is to introduce
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
中。但是,我不确定这与我的保护人规则有什么关系。
in build.gradle
. But, I'm not sure how that related to my proguard rule.
推荐答案
根据 Android文档,默认的proguard文件复制到目录 project-dir / build / intermediates / proguard-files /
。
According to Android Documentation the default proguard file is copied to directory project-dir/build/intermediates/proguard-files/
.
检查此目录是否存在。否则,您可能没有创建权限。这可能会导致问题。
Check if this directory exists. If not, you may have no permissions to create it. This can cause the problem.
这篇关于为什么构建过程会忽略proguardFiles getDefaultProguardFile('proguard-android.txt')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!