Unknown Source NullPointerException When Working With Expansion File

1.3k views Asked by At

I've added an expansion file to my app that has been working fine until recently. Whenever any file in the expansion file is opened, the app crashes with a NullPointerException. However, this only happens when the app is downloaded from the Play Store or an APK outside of Eclipse. When the app is run from Eclipse there is no such problem and all the files in the expansion work fine. My stack trace is slightly unhelpful because it tells me the problem is from an unknown source.

11-29 16:23:29.477: E/AndroidRuntime(3839): FATAL EXCEPTION: main
11-29 16:23:29.477: E/AndroidRuntime(3839): Process: net.multieducator.telaviv, PID: 3839
11-29 16:23:29.477: E/AndroidRuntime(3839): java.lang.NullPointerException
11-29 16:23:29.477: E/AndroidRuntime(3839):     at net.multieducator.telaviv.be.onCreateView(Unknown Source)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.support.v4.app.Fragment.performCreateView(Unknown Source)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.support.v4.app.BackStackRecord.run(Unknown Source)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(Unknown Source)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.support.v4.app.FragmentManagerImpl$1.run(Unknown Source)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.os.Handler.handleCallback(Handler.java:733)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.os.Handler.dispatchMessage(Handler.java:95)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.os.Looper.loop(Looper.java:136)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at android.app.ActivityThread.main(ActivityThread.java:5017)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at java.lang.reflect.Method.invokeNative(Native Method)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at java.lang.reflect.Method.invoke(Method.java:515)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-29 16:23:29.477: E/AndroidRuntime(3839):     at dalvik.system.NativeStart.main(Native Method)

Thanks for any help :)

1

There are 1 answers

0
Cosmittus On

You don't say whether you are using ProGuard in the release build but the difference in stability is consistent with issues I've had with it.

If your expansion file references classes in the main project, ProGuard's minifyenabled option may have obfuscated their names. If those names don't match up with the expansion file's expectations, a NullPointerException could occur.

Things to try:

  • Set minifyenabled to false and build again
  • If this results in a working version, add -keep class <your classes' package name>.** { *; } to the proguard-rules.pro file so that ProGuard will not obfuscate the class and member names in that package.
  • To build a development version that uses ProGuard in the the same manner as a release, in the build.gradle file copy release (under buildTypes) and call it debug.