android - 为什么构建过程会忽略proguardFiles getDefaultProguardFile ('proguard-android.txt')

标签 android crash build.gradle retrofit2

一直以来,我的构建过程没有任何问题。我正在使用最新的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/

相关文章:

Android 字符串资源引用

android - Android上的loopj http库: Activity 处于后台时回调

groovy - Gradle ant 构建文件在配置阶段不可用

gradle - `runBlocking` coroutine builder is not resolved in the project(其他builder已解析)

groovy - Gradle 额外属性不存在 - 在子模块中定义

android - 我可以在没有谷歌服务的设备上使用谷歌Firestore吗?

android - phonegap google play 和邮件链接

android - 隐藏安卓小部件

c - 我的程序经常崩溃

delphi - 在 Delphi 6 中加载特定帧会导致它立即退出