BhavyaKhandelwal
BhavyaKhandelwal

Reputation: 1

How to use Proguard?

hey i have developed an app but i wanted to ask how to enable proguard . I am just an amateur and dont know how to use it. THERE IS NO PROGAURD.CFG

-> This is my build.gradle

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.bhavya.whatsappplus"
    minSdkVersion 10
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),      'proguard-rules.pro'
    }
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:support-v4:21.0.3'
compile files('libs/StartAppInApp-2.4.11.jar')
compile files('libs/mobilecore.jar')
}

->This is progaurd-rules.pro

}
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-keep class com.startapp.** {
  *;
  }

-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile,LineNumberTable, *Annotation*, EnclosingMethod
 -dontwarn android.webkit.JavascriptInterface
 -dontwarn com.startapp.**

 -keepattributes InnerClasses, EnclosingMethod
 -keep class com.ironsource.mobilcore.**{ *; }

Upvotes: 0

Views: 947

Answers (1)

Trinimon
Trinimon

Reputation: 13957

This is how it works for me: file proguard-rules.txt in path /MyProject/

and the build.gradle contains:

buildTypes {
    release {
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        ....

See notes from the documentation:

"... getDefaultProguardFile('proguard-android.txt') obtains the default ProGuard settings from the Android SDK installation. Android Studio adds the module-specific rules file proguard-rules.txt at the root of the module, where you can add custom ProGuard rules. .."

Upvotes: 1

Related Questions