ncapdevi / FragNav

An Android library for managing multiple stacks of fragments
1.5k stars 220 forks source link

App Crashing When Using Proguard #149

Closed shreknitin89 closed 6 years ago

shreknitin89 commented 6 years ago

Hi, the app worked fine until I enabled proguard for my release version. Not sure if any one faced this issue before but it seems like the List is not getting properly initialized thus causing the app to crash. Luckily I got the stack trace and it's happening at the same place every single time. Below is the stack trace


       at java.util.ArrayList.get(ArrayList.java:411)
       at com.ncapdevi.fragnav.FragNavController.getCurrentFrag(Unknown Source:653)
       at com.ncapdevi.fragnav.FragNavController.clearDialogFragment(Unknown Source:523)
       at com.ncapdevi.fragnav.FragNavController.initialize(Unknown Source:162)
       at com.ncapdevi.fragnav.FragNavController.(Unknown Source:139)
       at com.ncapdevi.fragnav.FragNavController.(Unknown Source:44)
       at com.ncapdevi.fragnav.FragNavController$Builder.build(Unknown Source:1108)
       at com.emn8.mobilem8.nativeapp.bk.activities.MenuNavigationActivity.onPostCreate(Unknown Source:458)
       at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1207)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2906)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
       at android.app.ActivityThread.-wrap14(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6692)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)```
gildor commented 6 years ago

Show full crash log, you missed error message

shreknitin89 commented 6 years ago

Here is the full log

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.emn8.mobilem8.nativeapp.bk/com.emn8.mobilem8.nativeapp.bk.activities.MenuNavigationActivity}: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
       at android.app.ActivityThread.-wrap14(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6692)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

Caused by java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at java.util.ArrayList.get(ArrayList.java:411)
       at com.ncapdevi.fragnav.FragNavController.getCurrentFrag(Unknown Source:653)
       at com.ncapdevi.fragnav.FragNavController.clearDialogFragment(Unknown Source:523)
       at com.ncapdevi.fragnav.FragNavController.initialize(Unknown Source:162)
       at com.ncapdevi.fragnav.FragNavController.(Unknown Source:139)
       at com.ncapdevi.fragnav.FragNavController.(Unknown Source:44)
       at com.ncapdevi.fragnav.FragNavController$Builder.build(Unknown Source:1108)
       at com.emn8.mobilem8.nativeapp.bk.activities.MenuNavigationActivity.onPostCreate(Unknown Source:458)
       at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1207)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2906)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
       at android.app.ActivityThread.-wrap14(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6692)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
ncapdevi commented 6 years ago

Interesting. I use proguard and have never needed any specific rules regarding FragNav. And if you compile without using proguard and run it, nothing else changed, it works? Regardless, this particular error won't happen with the upcoming 3.0.0 release, but I still find it curious.

shreknitin89 commented 6 years ago

Yes if I disable proguard everything works. Not sure what is causing this, but its strange.

shreknitin89 commented 6 years ago

Hey guys sorry for the false positive, after spending a lot of time on trying to understand this I came to know that the issue was because of the other helper method I'm using to set the max tab count. The stack trace was not completely helpful as it shows the crashes on the library, but closing this as it is not the cause.

ncapdevi commented 6 years ago

That sounds about right. Thanks for the update and closing the issue.