Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating a Pro Guard configuration file with 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?

like image 370
Peter Osburg Avatar asked Aug 06 '13 18:08

Peter Osburg


2 Answers

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

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
        }
    }
}

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

like image 121
Ricardo Belchior Avatar answered Oct 18 '22 21:10

Ricardo Belchior


You can copy the default Proguard configuration file to your project.

sdk-location/tools/proguard/examples/android.pro — copy and paste it as proguard.cfg in your project. Then choose it when AS asks for the config file path.

like image 39
Naroh Avatar answered Oct 18 '22 22:10

Naroh