【发布时间】:2015-06-09 10:13:12
【问题描述】:
我想使用 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
【问题讨论】:
-
使用的 ProGuard 配置用于混淆 Android 应用程序,而不是库。您必须手动配置 ProGuard 以保留提供库 API 的类。
-
我发现 ProGuard 配置是用于混淆 Internet 上的 jar 文件。(库和 Jar 文件之间有什么区别吗?)。你能给我一些示例来保留我提供库 API 的类吗?非常感谢!
-
你必须了解 ProGuard 的工作原理。阅读手册:proguard.sourceforge.net/manual/examples.html#library
标签: java android eclipse jar proguard