My app was working fine, and I then included the support design library in the build.gradle
compile 'com.android.support:design:23.2.1'
Android Studio prompted to download more components and after that I started seeing way too many of these crashes when navigation b/w different fragments
FATAL EXCEPTION: main
Process: com.presdo.match.matchtemplate, PID: 23339
java.lang.NullPointerException: Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3197)
at android.view.View.draw(View.java:15234)
at android.widget.FrameLayout.draw(FrameLayout.java:598)
at android.view.View.updateDisplayListIfDirty(View.java:14167)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
at android.view.View.updateDisplayListIfDirty(View.java:14127)
at android.view.View.getDisplayList(View.java:14189)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2530)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2352)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1982)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
This is my build.gradle
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:23.+'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:percent:23.1.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:palette-v7:23.1.0'
I have already looked at this and I am not yet sure if it has something to do with my code.
Now, even if I remove the google design support library, I see the crashes, and not able to predict when they happen, since there is no reference to my project's code base in the stacktrace.
Any help is appreciated.
UPDATE
I made changes to the Gradle to make the support library versions consistent, and I don't see the crashes anymore. Here is a snippet
ext {
supportLibVersion = '23.2.1'
}
dependencies {
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:percent:${supportLibVersion}"
compile "com.android.support:palette-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
...
}
It is (again) an animation issue. You probably have some custom animations set with
fragmentTransaction.setCustomAnimations();
Remove them and it works again. Congratulations, you now have fragment transitions like 5 years ago.
Edit : a better way is to restore your old repository, by downloading
http://dl.google.com/android/repository/android_m2repository_r26.zip
and replacing everything in
/Users/.../Library/Android/sdk/extras/android/m2repository
Took it from here.