2013-09-24 79 views
3

我想混淆我的Android應用程序,我使用android.support.v7.appcompat和android.support.v7.GridLayout,但應用程序崩潰與以下 例外:Obfuscate android.support.v7.widget.GridLayout問題

android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.GridLayout 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
at com.droid.fragments.c.al.onCreateView(Unknown Source) 
at android.support.v4.app.Fragment.performCreateView(Unknown Source) 
at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source) 
at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source) 
at android.support.v4.app.BackStackRecord.run(Unknown Source) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(Unknown Source) 
at android.support.v4.app.FragmentManagerImpl$1.run(Unknown Source) 
at android.os.Handler.handleCallback(Handler.java:615) 
at android.os.Handler.dispatchMessage(Handler.java:92) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4745) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.ClassNotFoundException: android.support.v7.widget.GridLayout 
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 
at android.view.LayoutInflater.createView(LayoutInflater.java:552) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 

我ProGuard的-project.txt:

-dontusemixedcaseclassnames 
-dontskipnonpubliclibraryclasses 
-verbose 
-dontoptimize 
-dontpreverify 
-keepclasseswithmembernames class * { 
    native <methods>; 
} 

-keepattributes *Annotation*,EnclosingMethod,Signature 

-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 

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

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

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

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

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

-keep class * implements android.os.Parcelable { 
    public static final android.os.Parcelable$Creator *; 
    public void set*(***); 
    public *** get*(); 
    public *** is*(); 
} 

-keepclassmembers class **.R$* { 
    public static <fields>; 
} 

-keep class android.support.v7.widget.** { *; } 
-keep class android.support.v7.internal.** { *; } 
-keep interface android.support.v7.internal.** { *; } 
-keep class android.support.v4.widget.** { *; } 
-keep interface android.support.v4.widget.** { *; } 
-keep class com.viewpagerindicator.** { *; } 

-keep class android.support.v4.app.** { *; } 
-keep class android.support.v4.view.** { *; } 
-keep interface android.support.v4.app.** { *; } 
-keep interface android.support.v4.view.** { *; } 

我怎樣才能解決這個問題呢?

回答

1

我使用的是類似的東西(也可能是過於寬泛雖然):

# Preserve all fundamental application classes. 
-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.view.View 
-keep public class * extends android.preference.Preference 
-keep public class * extends android.content.BroadcastReceiver 
-keep public class * extends android.content.ContentProvider 

# Preserve Android support libraries` classes and interfaces 
-keep class android.support.** { *; } 
-keep interface android.support.** { *; } 
5
#### -- Support Library -- 

# support-v4 
-dontwarn android.support.v4.** 
-keep class android.support.v4.app.** { *; } 
-keep interface android.support.v4.app.** { *; } 
-keep class android.support.v4.** { *; } 

# support-v7 
-dontwarn android.support.v7.** 
-keep class android.support.v7.internal.** { *; } 
-keep interface android.support.v7.internal.** { *; } 
-keep class android.support.v7.** { *; } 
+1

你錯過了''-keep類android.support.v7 ** {*; }'' –

相關問題