尝试在项目中使用Proguard进行收缩,优化和混淆。
我正在项目中使用以下外部库。
- ActionBarSherlok : com.actionbarsherlock
- SherlokNavigationDrawer : com.sherlock.navigationdrawer
- GoogleplayLib : com.google.android.gms
- ViewPagerIndicator : com.viewpagerindicator
- MyAppPackage : ...
- External Jar used are
- HttpMime :
- GoogleAnalytics
- Crittercism
- UniversalImageLoader
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# repackage and optimize
-repackageclasses "com.example.data"
# Keep a fixed source file attribute and all line number tables to get line
# numbers in the stack traces.
# You can comment this out if you're not interested in stack traces.
#-renamesourcefileattribute SourceFile
#-keepattributes SourceFile,LineNumberTable
# keep annotations
-keepattributes *Annotation*
# keep the licencing service classes from Google
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# an example on how to keep an entire package
# -keep class com.google.zxing.**
#############################################################################
#-keep class com.data.metro.services.**
-keep class com.actionbarsherlock.** { *; }
-keep class com.sherlock.navigationdrawer.** { *; }
-keep class com.viewpagerindicator.** { *; }
-libraryjars libs
-keep class crittercism.sdk.** { *; }
-keep class crittercism.android.** { *; }
-keep class org.apache.http.entity.mime.** { *; }
-keep class google.ads.** { *; }
-keep class google.analytics** { *; }
-keep class google.android.gms.** { *; }
-keep class google.tagmanager.** { *; }
-keep class com.nostra13.universalimageloader.** { *; }
#############################################################################
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
# an example if you don't want to be warned about missing libraries
# -dontwarn javax.naming.**
#############################################################################
# remove logging, note that this removes ALL logging, including the
# Log.e statements
-assumenosideeffects class android.util.Log {
*;
}
#-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
#-optimizationpasses 5
#-allowaccessmodification
#-dontpreverify
导出应用程序后,它根本不起作用。 原因是代码没有正确收缩它也删除了一些使用过的代码,我在使用dex2jar和jdgui看到代码时发现了这一点。
需要建议,此proguard.cfg配置文件需要进行哪些更改。
答案 0 :(得分:0)
我认为您需要在Proguard文件中添加行来告诉缩小所有有用的代码。
因此,要包含SherLock代码,您需要在Proguard中添加所有有用的类
-keep class com.example.classname.**{
*;
}
-keep interface com.example.classname.**{
*;
}
并将Jars用于以下行
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar
-libraryjars /libs/nameofjarfile.jar
就像上面的这些行一样。
希望它会对你有所帮助。 请尝试让我知道
答案 1 :(得分:0)
我认为您需要导入库才能进行正确的编译。尝试使用以下参数(例如):
-injars libary1.jar
-libraryjars '/Java/jre6/lib/rt.jar'