2013-08-10 6 views
1

Я получаю следующее сообщение об ошибке во время тестирования моего приложения в режиме выпуска, с Proguard запутыванием:Android Holoeverywhere Proguard ад

08-09 21:44:06.140: E/AndroidRuntime(4465): FATAL EXCEPTION: main 
08-09 21:44:06.140: E/AndroidRuntime(4465): java.lang.ExceptionInInitializerError 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at java.lang.Class.newInstanceImpl(Native Method) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at java.lang.Class.newInstance(Class.java:1409) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.app.Instrumentation.newApplication(Instrumentation.java:957) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.app.Instrumentation.newApplication(Instrumentation.java:942) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.app.LoadedApk.makeApplication(LoadedApk.java:461) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3264) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.app.ActivityThread.access$2200(ActivityThread.java:117) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.os.Handler.dispatchMessage(Handler.java:99) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.os.Looper.loop(Looper.java:123) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at android.app.ActivityThread.main(ActivityThread.java:3687) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at java.lang.reflect.Method.invokeNative(Native Method) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at java.lang.reflect.Method.invoke(Method.java:507) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at dalvik.system.NativeStart.main(Native Method) 
08-09 21:44:06.140: E/AndroidRuntime(4465): Caused by: java.lang.RuntimeException: SystemServiceCreator must be implement SystemService 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at org.holoeverywhere.SystemServiceManager.register(Unknown Source) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  at org.holoeverywhere.app.Application.<clinit>(Unknown Source) 
08-09 21:44:06.140: E/AndroidRuntime(4465):  ... 16 more 

Моим файл proguard.txt:

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

-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 *; 
} 

-keepattributes Signature 

-keep class sun.misc.Unsafe { *; } 

-keep class org.springframework.** { *; } 
-keep class org.codehaus.jackson.** { *; } 
-keep class org.holoeverywhere.** { *; } 
-keep class com.actionbarsherlock.** { *; } 
-keep class com.facebook.** { *; } 

-dontwarn org.springframework.** 
-dontwarn org.apache.** 

-libraryjars libs/commons-collections-3.2.1.jar 
-libraryjars libs/congregando-message-1.0.0-SNAPSHOT.jar 
-libraryjars libs/gson-2.2.3.jar 
-libraryjars libs/spring-android-auth-1.0.1.RELEASE.jar 
-libraryjars libs/spring-android-core-1.0.1.RELEASE.jar 
-libraryjars libs/spring-android-rest-template-1.0.1.RELEASE.jar 

Если я отключить запутывание , приложение работает нормально. Не могли бы вы рассказать мне, что происходит?

+1

Попробуйте добавить -keepattributes * Аннотация *, см. Документацию по proguard по аннотациям. –

+0

Большое спасибо! Это решило проблему !! – andresmafra

ответ

3

Ошибка в SystemServiceManager.java от Holoeverywhere. Если прочитать код вы заметили, что он намеренно бросает ошибку, как что-то происходит не так с аннотациями

public static void register(Class<? extends SystemServiceCreator<?>> clazz) { 
    if (!clazz.isAnnotationPresent(SystemService.class)) { 
     throw new RuntimeException(
       "SystemServiceCreator must be implement SystemService"); 
    } 
    SystemService systemService = clazz.getAnnotation(SystemService.class); 
    final String name = systemService.value(); 
    if (name == null || name.length() == 0) { 
     throw new RuntimeException("SystemService has incorrect name"); 
    } 
    MAP.put(name, clazz); 
} 

Проверка на proguard troubleshooting document показывает, что по умолчанию он удаляет аннотации, если вы добавить

-keepattributes *Annotation*