title: Proguard: App crashes after obfuscating
body: <p>I haven't used ProGuard before so im probably overlooking something here. </p>
  
  <p>The issue is as follows: I have to obfuscate my Android Studio project. I got past the build issues and am able to run my release build (with proguard enabled) on a test device. The app starts up and as soon as I press the login button it crashes. Logcat gives the following output for the error:</p>
  
  <pre><code>E/AndroidRuntime﹕ FATAL EXCEPTION: main
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.packagename/com.packagename.activity.MainWebActivity}: android.view.InflateException: Binary XML file line #48: Error inflating class fragment
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
              at android.app.ActivityThread.access$700(ActivityThread.java:159)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
              at android.os.Handler.dispatchMessage(Handler.java:99)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:5419)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:525)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
              at dalvik.system.NativeStart.main(Native Method)
       Caused by: android.view.InflateException: Binary XML file line #48: Error inflating class fragment
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
              at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
              at android.app.Activity.setContentView(Activity.java:1956)
              at com.packagename.activity.MainWebActivity.onCreate(Unknown Source)
              at android.app.Activity.performCreate(Activity.java:5372)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
              at android.app.ActivityThread.access$700(ActivityThread.java:159)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
              at android.os.Handler.dispatchMessage(Handler.java:99)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:5419)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:525)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
              at dalvik.system.NativeStart.main(Native Method)
       Caused by: java.lang.NullPointerException
              at com.packagename.fragment.DrawerMenuFragment.a(Unknown Source)
              at com.packagename.fragment.DrawerMenuFragment.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.FragmentManagerImpl.addFragment(Unknown Source)
              at android.support.v4.app.FragmentActivity.onCreateView(Unknown Source)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
              at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
              at android.app.Activity.setContentView(Activity.java:1956)
              at com.packagename.activity.MainWebActivity.onCreate(Unknown Source)
              at android.app.Activity.performCreate(Activity.java:5372)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
              at android.app.ActivityThread.access$700(ActivityThread.java:159)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
              at android.os.Handler.dispatchMessage(Handler.java:99)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:5419)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:525)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>After the LoginActivity the app starts a WebView activity which holds the DrawerLayout. My proguard-project.txt looks as follows:</p>
  
  <pre><code>-optimizationpasses 5
  -dontusemixedcaseclassnames
  -dontskipnonpubliclibraryclasses
  -dontpreverify
  -verbose
  -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
  -keepattributes *Annotation*
  
  
  -keep public class * extends android.app.Activity
  -keep public class * extends android.support.v4.app.FragmentActivity
  -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.preference.Preference
  -keep public class * extends android.view.View {
      public &lt;init&gt;(android.content.Context);
      public &lt;init&gt;(android.content.Context, android.util.AttributeSet);
      public &lt;init&gt;(android.content.Context, android.util.AttributeSet, int);
      public void set*(...);
  }
  
  # Explicitly preserve all serialization members. The Serializable interface
  # is only a marker interface, so it wouldn't save them.
  -keepclassmembers class * implements java.io.Serializable {
      static final long serialVersionUID;
      private static final java.io.ObjectStreamField[] serialPersistentFields;
      private void writeObject(java.io.ObjectOutputStream);
      private void readObject(java.io.ObjectInputStream);
      java.lang.Object writeReplace();
      java.lang.Object readResolve();
  }
  
  -keepclasseswithmembers class * {
      public &lt;init&gt;(android.content.Context, android.util.AttributeSet);
  }
  
  -keepclasseswithmembers class * {
      public &lt;init&gt;(android.content.Context, android.util.AttributeSet, int);
  }
  
  -keepclassmembers class * extends android.content.Context {
      public void *(android.view.View);
      public void *(android.view.MenuItem);
  }
  
  -keepclassmembers class * implements android.os.Parcelable {
      static android.os.Parcelable$Creator CREATOR;
  }
  
  -keepclassmembers class **.R$* {
      public static &lt;fields&gt;;
  }
  
  -keepclasseswithmembernames class * {
      native &lt;methods&gt;;
  }
  -keepclassmembers class * {
      public void *ButtonClicked(android.view.View);
  }
  
  -keep public class * extends android.support.v4.app.Fragment
  -keep public class * extends android.app.Fragment
  
  -keepclassmembers public class * extends android.view.View {
        void set*(***);
        *** get*();
      }
  
  -libraryjars libs
  
  # The official support library.
  -keep class android.support.v4.** { *; }
  -keep interface android.support.v4.** { *; }
  
  # Facebook library
  -keep class com.facebook.** {
     *;
  }
  
  -dontwarn com.squareup.okhttp.**
  
  # Make sure that Google Analytics doesn't get removed
  -keep class com.google.analytics.tracking.android.CampaignTrackingReceiver
  
  # Gson uses generic type information stored in a class file when working with fields. Proguard
  # removes such information by default, so configure it to keep all of it.
  -keepattributes Signature
  
  # Gson specific classes
  -keep class sun.misc.Unsafe { *; }
  -keep class com.google.gson.** { *; } 
  </code></pre>
  
  <p>I suspect that there is something missing in my proguard-project.txt. I know it is an issue with the obfuscating because when I add -dontobfuscate it will run without errors.</p>
  
  <p>What am I missing here?</p>
  
  <p><em><strong>EDIT:</em></strong> I was able to discover what was going on by adding
  <code>-keepattributes SourceFile,LineNumberTable</code>
  In my case it had something to do with a usermodel.</p>