2017-01-19 3 views
0

Я пытаюсь применить proguard в приложении на основе анализа. И попробовал всевозможную комбинацию перестановок, но кое-где я не могу достичь. Если кто-то поможет мне сделать мой код стандартизованным и помочь мне удалить избыточность. Это мое приложение (Gradle)Parse, ParseFacebookUtils Исключения ProGuard

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:[email protected]' 
    compile 'com.parse:parsefacebookutils-v4-android:[email protected]' 
    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:[email protected]'){ 
     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:[email protected]') { 
     transitive = true; 
    } 
    compile 'com.mcxiaoke.volley:library:1.0.19' 
} 
apply plugin: 'com.google.gms.google-services' 
} 

Вот мой 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.** 

Есть так много решений, рассеянных. Я нахожу большинство конфликтов между болтом библиотеки. Я больше не использую Parse_abc.jar.

+0

Ошибка: выполнение выполнено для задачи ': app: transformClassesAndResourcesWithProguardForProdDebug'. > java.io.IOException: невозможно написать [/home/owais/AndroidStudioProjects/apptitude/app/build/intermediates/transforms/proguard/prod/debug/jars/3/1f/main.jar] (не может прочитайте [/home/owais/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-android/1.2.1/44780c2cf98f6a3cf4e77f1234d644758b329201/bolts-android-1.2.1.jar (;;;; ;] **. class)] (Дубликат zip entry [bolts-android-1.2.1.jar: bolts/AggregateException.class])) –

ответ

0

Вот как решается это Был дубликат входа для болтов андроида вложенными различной библиотеки. Я просто исключил их из app.gradle. Также обновлены все версии библиотеки и buildToolVersions в 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:[email protected]') { 
     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:[email protected]') { 
     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' 

И это мой окончательный 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.** 

Хотя у меня нет полного понимания, а также не в состоянии объяснить вам в консолидированный способ. Но Google и моя комбинация перестановок дали мне этот результат. Я все еще тестирую приложение для любого сбоя. В этом случае я также обновлю этот ответ.

0

Используйте LIB Ткани для функциональности использования facebook, а также определить его к вашему progaurd-rules.pro

+0

Я использую ParseFacebookUtils только для целей входа. А также добавил crashlytics в конце proguard-rules.pro. Если бы вы могли разработать свой ответ, это помогло бы. –

Смежные вопросы