Obfuscate android.support.v7.widget.GridLayout issue
Asked Answered
F

2

3

I'm trying to obfuscate my android application, where I use android.support.v7.appcompat and android.support.v7.GridLayout, but the app is crashing with the following exception:

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)

My 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.** { *; }  

How can I resolve this problem?

Fisticuffs answered 24/9, 2013 at 10:11 Comment(0)
P
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.** { *; }
Pricillaprick answered 19/12, 2013 at 9:33 Comment(1)
You missed -keep class android.support.v7.** { *; }Slant
B
1

I'm using something like that (it may be too broad though):

# 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.** { *; }
Bascinet answered 24/9, 2013 at 10:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.