I am trying to apply proguard on app based on parse. And tried all sort of permutation combination but here and there I am not able to achive. If someone to help me make my code standardized and help me remove any redundancy. This is my app(gradle)
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example"
minSdkVersion 15
targetSdkVersion 24
versionCode 27
versionName "1.2.27"
}
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
multiDexEnabled true
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 19
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/maven/com.squareup.picasso/picasso/pom.properties'
exclude 'META-INF/maven/com.squareup.picasso/picasso/pom.xml'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
/*
compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'
compile 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
compile files('libs/ParseFacebookUtilsV4-1.10.1.jar')
*/
/*
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
*/
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
/*compile fileTree(include: 'Parse-*.jar', dir: 'libs')*/
/*compile files('libs/volley.jar')*/
compile files('libs/pgsdk.jar')
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
/* compile 'com.parse.bolts:bolts-android:1.2.1'*/
compile 'com.parse:parse-android:1.13.1'
compile('com.facebook.android:facebook-android-sdk:4.8.2') {
exclude module: 'bolts-android'
exclude module: 'support-v4'
}
compile ('com.parse:parsefacebookutils-v4-android:1.10.4@aar'){
transitive=true
}
compile 'com.parse:parsetwitterutils-android:1.10.5'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v13:24.0.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.google.android.gms:play-services-ads:9.8.0'
compile 'com.google.android.gms:play-services-identity:9.8.0'
compile 'com.google.android.gms:play-services-gcm:9.8.0'
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-auth:9.8.0'
compile 'com.google.android.gms:play-services-places:9.8.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
}
compile 'com.mcxiaoke.volley:library:1.0.19'
}
apply plugin: 'com.google.gms.google-services'
}
Here is my progaurd-rules.pro
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/android/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
#common
-dontobfuscate
#-dontoptimize
# attributes
-keepattributes InnerClasses, Signature, *Annotation*, Exceptions
#Current Project packages
-keep class com.example.**{*;}
-keep interface com.example.**{*;}
#Paytm
-keep class com.paytm.**{*;}
# java
-dontwarn javax.naming.**
-dontwarn java.lang.invoke**
-dontwarn java.nio.file.Files
-dontwarn java.nio.file.Path
-dontwarn java.nio.file.OpenOption
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
#retrofit
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
# gson
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
# otto
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}
# google play services
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
#appengine
-keep class com.google.appengine.api.urlfetch.**{*;}
-keep interface com.google.appengine.api.urlfetch.**{*;}
-dontwarn com.google.appengine.api.**
#DOM
-keep class org.w3c.dom.bootstrap.DOMImplementationRegistry{*;}
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
#joda
-keep class org.joda.convert.**{*;}
-keep interface org.joda.convert.**{*;}
-dontwarn org.joda.convert.**
# support
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
# Keep source file names, line numbers, and Parse class/method names for easier debugging
-keepattributes SourceFile,LineNumberTable
-keepnames class com.parse.** { *; }
-keep class com.parse.** { *; }
# Required for Parse
-dontwarn com.squareup.**
-dontwarn okio.**
-dontwarn com.parse.**
-keepnames class com.fasterxml.jackson.** { *; }
#-keep class com.shaded.fasterxml.jackson.** { *; }
-keep class com.fasterxml.jackson.databind.ObjectMapper {
public <methods>;
protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
public ** writeValueAsString(**);
}
#piccaso
#-keep class com.squareup.picasso.**{*;}
#-keep interface com.squareup.picasso.**{*;}
-keep class org.apache.** { *; }
-dontwarn org.apache.**
-dontwarn android.net.SSLCertificateSocketFactory
-dontwarn android.app.Notification
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
There are so many solutions scattered. I find most conflicts between bolt library. I am not using Parse_abc.jar any more.
Here is how solved it There was duplicate entry for bolt-android nested inside various library. I just excluded them from app.gradle. Also updated all library versions and buildToolVersions to 25.0.0
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example"
minSdkVersion 15
targetSdkVersion 25
versionCode 27
versionName "1.2.27"
}
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
multiDexEnabled true
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 19
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/maven/com.squareup.picasso/picasso/pom.properties'
exclude 'META-INF/maven/com.squareup.picasso/picasso/pom.xml'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//compile fileTree(include: ['*.jar'], dir: 'libs')
/*compile fileTree(include: 'Parse-*.jar', dir: 'libs')*/
/*compile files('libs/volley.jar')*/
compile files('libs/pgsdk.jar')
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
//compile 'com.parse.bolts:bolts-android:1.2.1'
compile ('com.parse:parse-android:1.13.1'){
exclude module: 'bolts-android'
}
compile('com.facebook.android:facebook-android-sdk:4.8.2') {
exclude module: 'bolts-android'
exclude module: 'support-v4'
}
compile('com.parse:parsefacebookutils-v4-android:1.10.4@aar') {
transitive = true
exclude module: 'bolts-android'
}
compile 'com.parse:parsetwitterutils-android:1.10.5'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v13:25.1.0'
compile 'com.google.android.gms:play-services-location:10.0.1'
//compile 'com.google.android.gms:play-services-appindexing:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.google.android.gms:play-services-identity:10.0.1'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.android.gms:play-services-plus:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
exclude module: 'bolts-android'
exclude module: 'support-v4'
}
compile 'com.mcxiaoke.volley:library:1.0.19'
}
apply plugin: 'com.google.gms.google-services'
And this is my final proguard-rules.pro
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/android/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
#common
-dontobfuscate
#-dontoptimize
# attributes
-keepattributes InnerClasses, *Annotation*
#Current Project packages
-keep class com.example.**{*;}
-keep interface com.example.**{*;}
#Paytm
-keep class com.paytm.**{*;}
# java
-dontwarn javax.naming.**
-dontwarn java.lang.invoke**
-dontwarn java.nio.file.Files
-dontwarn java.nio.file.Path
-dontwarn java.nio.file.OpenOption
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
#retrofit
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
# gson
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
# otto
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}
# google play services
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
#appengine
-keep class com.google.appengine.api.urlfetch.**{*;}
-keep interface com.google.appengine.api.urlfetch.**{*;}
-dontwarn com.google.appengine.api.**
#DOM
-keep class org.w3c.dom.bootstrap.DOMImplementationRegistry{*;}
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
#joda
-keep class org.joda.convert.**{*;}
-keep interface org.joda.convert.**{*;}
-dontwarn org.joda.convert.**
# support
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
# Keep source file names, line numbers, and Parse class/method names for easier debugging
-keepattributes SourceFile,LineNumberTable
-keepnames class com.parse.** { *; }
-keep class com.parse.** { *; }
-dontwarn com.parse.ParseOkHttpClient**
# Required for Parse
-keep class com.squareup.** { *; }
-dontwarn com.squareup.**
-dontwarn okio.**
-dontwarn android.net.SSLCertificateSocketFactory
-dontwarn android.app.Notification
-keep class org.apache.http.** { *; }
-keep interface org.apache.http.** { *; }
-dontwarn org.apache.http.**
-keep class javax.servlet.** { *; }
-keep class org.ietf.jgss.** { *; }
#crashlytics fabric
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
Though I have no complete understanding and wont be able to explain you in a consolidated way. But Google and my permutation combination have yield me this result. I am still testing app for any crash. In that case I will update this answer too.