1

I got proguard to work correctly, but the problem is that I have a library project inside my project, so when proguard does its magic the library doesn't recognize the classes (vice-versa).

How to use proguard correctly when I have a library project? how to keep both projects link to each others' classes correctly? Any help is much appreiciated guys.

Here's my App's build file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {



    applicationId "com.ex.test"
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
}

}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.2'
    compile 'com.android.support:cardview-v7:21.0.2'
    compile 'com.android.support:recyclerview-v7:21.0.2'
    compile 'com.mcxiaoke.volley:library:1.0.+'
    compile 'com.android.support:support-annotations:21.0.2'
    compile 'com.android.support:support-v4:21.0.2'
    compile project(':chatinglibrary')
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.koushikdutta.ion:ion:2.+'
    compile 'com.github.amlcurran.showcaseview:library:5.0.0'
    compile 'com.afollestad:material-dialogs:0.7.6.0'
}

And here's my lib's build file:

apply plugin: 'com.android.library'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        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.firebase:firebase-client-android:2.0.3+'
}
Ahmed Awad
  • 1,787
  • 3
  • 16
  • 22
  • Can you post your build.gradle for main and library projects? – random Sep 13 '15 at 10:43
  • I think you don't need to enable proguard for your library project. Your main application has proguard enabled and it will obfuscate your library project files too. Check here: http://stackoverflow.com/questions/10982344/is-proguard-cfg-needed-for-library-projects#10992604 – random Sep 13 '15 at 10:53
  • Tried it, the library code won't obfuscate thus errors will produce.. – Ahmed Awad Sep 14 '15 at 07:37

1 Answers1

0

you must keep your each libs from proguard like this

   -keep class android.support.v4.app.** { *; }
   -keep interface android.support.v4.app.** { *; }

some libs have special ruls to keep from proguad

see example

and see this answer

Hamid Zandi
  • 2,714
  • 24
  • 32