ProguardGui使我的android jar错过了许多课程

时间:2015-06-09 10:13:13

标签: java android eclipse jar proguard

我想使用Proguard来混淆我的Android jar,它有近3000个类,但是,当我使用Proguard来混淆它时,我发现输出jar只有1个类!谁能帮助我,我将不胜感激! 我发布了

下面的配置和输出日志

Proguard配置

 -injars 'E:\Users\DalenRuan\workspace\Predictor_lib\predictor_lib.jar'
-outjars 'E:\Users\DalenRuan\workspace\Predictor_lib\out_predictor_lib.jar'

-libraryjars 'E:\adt-bundle-windows-x86-20140702\sdk\platforms\android-18\android.jar'
-libraryjars 'E:\Users\DalenRuan\workspace\Predictor_lib\libs\httpmime-4.1.1.jar'

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-optimizationpasses 5
-dontusemixedcaseclassnames
-verbose
-dontoptimize
-ignorewarning

-keep public class * extends android.app.Activity

-keep public class * extends android.app.Application

-keep public class * extends android.app.Service

-keep public final class *

输出日志

Reading input...
Reading program jar [E:\Users\DalenRuan\workspace\Predictor_lib\predictor_lib.jar]
Reading library jar [E:\adt-bundle-windows-x86-20140702\sdk\platforms\android-18\android.jar]
Reading library jar [E:\Users\DalenRuan\workspace\Predictor_lib\libs\httpmime-4.1.1.jar]
Initializing...
Note: the configuration refers to the unknown class 'our.company.project.ProjectAPI'
Note: the configuration refers to the unknown class 'our.company.project.ProjectAPI'
Note: there were 2 references to unknown classes.
      You should check your configuration for typos.
Ignoring unused library classes...
  Original number of library classes: 3305
  Final number of library classes:    411
Shrinking...
Removing unused program classes and class elements...
  Original number of program classes: 241
  Final number of program classes:    1
Inlining subroutines...
Optimizing...
  Number of finalized classes:                 0
  Number of vertically merged classes:         0   (disabled)
  Number of horizontally merged classes:       0   (disabled)
  Number of removed write-only fields:         0   (disabled)
  Number of privatized fields:                 0   (disabled)
  Number of inlined constant fields:           0   (disabled)
  Number of privatized methods:                0
  Number of staticized methods:                0
  Number of finalized methods:                 0
  Number of removed method parameters:         0
  Number of inlined constant parameters:       0
  Number of inlined constant return values:    0
  Number of inlined short method calls:        0
  Number of inlined unique method calls:       0
  Number of inlined tail recursion calls:      0
  Number of merged code blocks:                0
  Number of variable peephole optimizations:   0
  Number of arithmetic peephole optimizations: 0   (disabled)
  Number of cast peephole optimizations:       0
  Number of field peephole optimizations:      0
  Number of branch peephole optimizations:     0
  Number of string peephole optimizations:     0
  Number of simplified instructions:           0
  Number of removed instructions:              0
  Number of removed local variables:           0
  Number of removed exception blocks:          0
  Number of optimized local variable frames:   0
Obfuscating...
Preverifying...
Writing output...
Preparing output jar [E:\Users\DalenRuan\workspace\Predictor_lib\out_predictor_lib.jar]
  Copying resources from program jar [E:\Users\DalenRuan\workspace\Predictor_lib\predictor_lib.jar]
Processing completed successfully

1 个答案:

答案 0 :(得分:0)

您应该为您在build.gradle文件的依赖项中声明的每个API和jar搜索proguard配置。例如,如果您使用的是fabric api,则可以从此处的文档中获取proguard代码 https://docs.fabric.io/android/crashlytics/dex-and-proguard.html 或者如果你在代码中使用凌空,那么你必须写 -keep class com.android.volley。** {*; } 等等, 不要在开始时使用-ignorewarnings 尝试使用-dontwarn抑制警告,以获取依赖项的相应错误 最重要的是以下列方式包含所有java类

##Keep classes that are referenced on the AndroidManifest
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.preference.Preference

-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.preference.Preference

#
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}
#
##support libs(cab be used more wisely)
-keep class android.support.v4.** { *; }
-keep class android.support.v7.** { *; }
-keep public class * extends android.support.v4.**
-keep public class * extends android.support.v7.**

    ##Fragments
-keep public class * extends android.app.Fragment

    -keep class com.your-packagename.**{ *; }

最后,您还可以使用-dontnote删除重复的jar等消息 例如:-dontnote org.apache.http.** Lastly refer the documentation here https://www.guardsquare.com/en/proguard/manual/examples https://www.guardsquare.com/en/proguard/manual/troubleshooting Thanks