在打包apk时,Ant似乎忽略了Proguard生成的jar

时间:2012-06-06 14:11:13

标签: android ant proguard

我有一个Jenkins构建服务器,用于使用ant和Android(SDK Revision 18)构建Android APK。发布APK工作正常。但是,如果我通过提供proguard.cfg启用proguard并通过project.properties中的“proguard.config = proguard.cfg”指向它,则会发生以下情况:

执行Proguard(从shell输出看,后来存在mappings.txt和seeds.txt) 生成一个apk。然而,由APK生成的Stacktraces根本不会被混淆。

有人对此有所了解吗?似乎由proguard生成的jar由于某些原因而不包含在apk中。


这是我的Proguard配置

  

- 优化通过5       -dontusemixedcaseclassnames       -dontskipnonpubliclibraryclasses       -dontpreverify       -verbose       -optimizations!code / simplifiedification / arithmetic,!field / ,! class / merge /

-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.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

#ACRA specifics
# we need line numbers in our stack traces otherwise they are pretty useless
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# ACRA needs "annotations" so add this... 
-keepattributes *Annotation*

# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {
        *;
}

# keep this around for some enums that ACRA needs
-keep class org.acra.ReportingInteractionMode {
   *;
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
public void addCustomData(java.lang.String,java.lang.String);
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
public org.acra.ErrorReporter$ReportsSenderWorker handleSilentException(java.lang.Throwable);
}

mappings.txt声明我的代码被混淆了:

de.cellular.crashtest.ObfuscateThisClass -> de.cellular.crashtest.b:

然而,在报告的Stacktrace

中没有混淆

1 个答案:

答案 0 :(得分:0)

这似乎只是一个jenkins配置问题:apk是从bin/目录归档的,但是混淆的版本在release/