Proguard只保留一个没有混淆的类

时间:2017-02-14 21:11:56

标签: java android

调试我的应用程序两天而没有发现任何问题!

这里是我的build.gradle(使用Gson 2.2.4,Volley,itextpdf):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

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

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    compile 'com.google.android.gms:play-services-appindexing:8.1.0'
}

在这里我的计划配置:

-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

# Prevent proguard from stripping interface information from     TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

-keep class com.android.volley.** { *; }
-keep class org.apache.commons.logging.**

-keepattributes *Annotation*

-keep class com.itextpdf.** 

除了使用Volley + Gson库的重要部分(Sync Class)之外,我的应用程序工作正常。

同步课程的路径为:com/magicapp/sync.java

如何混淆除itextpdf库和sync.java之外的所有应用程序?

错误:

Warning: com.android.volley.toolbox.Volley: can't find referenced class android.net.http.AndroidHttpClient
Warning: com.android.volley.toolbox.Volley: can't find referenced class android.net.http.AndroidHttpClient
Warning: com.itextpdf.awt.AsianFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.AsianFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.AsianFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.AsianFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font

0 个答案:

没有答案