使用 Android Studio 生成 Pro Guard 配置文件 [英] Generating a Pro Guard configuration file with Android Studio

查看:23
本文介绍了使用 Android Studio 生成 Pro Guard 配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 0.1.0 开始使用 Android Studio ......我昨天才知道 Pro Guard 似乎集成在新创建的项目中.不幸的是,这对我的项目(这是一个以前的 Eclipse 项目)来说并非如此.在我开始使用 Android Studio 之前,我不知道 Pro Guard.现在我正在寻找有关如何在 Android Studio 中使用 Pro Guard 的示例.不幸的是,Android Dev 文档仅提及已创建配置文件的情况.是否有可能让 Android Studio 为现有项目创建配置文件?

I am using Android Studio since 0.1.0 ... I just learned yesterday that Pro Guard seems to be integrated in newly created projects. Unfortunately this is not true for my project (which was a former Eclipse project). I didn't know of Pro Guard until I started working with Android Studio. And now I am looking for examples on how to use Pro Guard with Android Studio. Unfortunately the Android Dev documentation is only mentioning situations where the configuration file is already created. Is there a possibility to get Android Studio to create a configuration file to an already existing project?

推荐答案

我也无法通过 Android Studio 完成.但是,这对我有用.

I was also not able to do it through Android Studio. However, this worked for me.

将以下部分添加到 build.gradle 文件的android"部分,在适当的地方填写您自己的实现细节.

Add the following sections to the "android" section of your build.gradle file, filling in your own implementation details where appropriate.

android {

...

    signingConfigs {
        releaseConfig {
            storeFile file("/dir/to/your.keystore")
            storePassword "xxx"
            keyAlias "yyy"
            keyPassword "xxx"
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../your_proguard_file.txt'
            signingConfig signingConfigs.releaseConfig
        }
    }
}

在您的项目文件夹中,运行 ./gradlew clean./gradlew assembleRelease

In your project folder, run ./gradlew clean and ./gradlew assembleRelease

这篇关于使用 Android Studio 生成 Pro Guard 配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆