android - 在 Android Studio 中的所有模块的顶层构建文件中设置 proguard

标签 android gradle android-studio proguard

我的项目目前包含三个模块,它们都应该在构建时被混淆。

现在我不想为每个模块定义一个 proguard 配置,而是为所有模块定义一个配置。

有 build.gradle 顶层构建脚本,对所有模块都有效

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.12.2'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
    jcenter()
}
}

如何在此文件中配置 proguard,以便为我的所有模块执行?

最佳答案

您可以将 proguard 文件存储在项目扩展属性中,然后从每个模块访问它:

项目 build.gradle:

allprojects {

    project.ext {
        proguardFile = "myproguardfile.txt"
    }

    repositories {
    }
}

模块:
buildTypes {
    release {
        runProguard false
        proguardFiles project.ext.proguardFile
    }
}

关于android - 在 Android Studio 中的所有模块的顶层构建文件中设置 proguard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25339371/

相关文章:

android - TrafficStats 特定应用-特定网络接口(interface)

android - `.gitignore` 用于具有 Android 目标的 Ionic 项目

android - 在Android中找不到FirebaseInitProvider

java - 无法将 gdx-tools 添加到 libgdx gradle 项目

android-studio - Intellij IDEA 无法 ctrl + v 'Create New Class' 的名称

java - 文件未找到异常 facebook 图

java - 创建签名的 bundle 版本。错误 : Android resource linking failed

Gradle clean <customTask> 不工作

android - 更新到 AS 3.0 Canary 6 后 transformClassesWithDesugar 构建错误

android - 如何在Android Studio中以编程方式在运行时设置构建变体?