I have an Android app that works fine in debug mode but started giving issues in release mode. It crashes while binding items to a recyclerview.
Initially I thought this would be a proguard issue, but after enabling proguard for debug mode it became clear that only the release version had this issue. Just to try it out, I set the release version as debuggable true
and the problem is gone.
Does anyone have an idea what could cause a crash only if the apk is not debuggable? Or any way to debug this and see what exactly is going wrong?
These are my buildtypes:
buildTypes {
debug {
multiDexEnabled true
shrinkResources true
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
multiDexEnabled true
shrinkResources true
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
So, if I add debuggable true
to release
, the release version works. If I add debuggable false
to debug
, the debug version stops working...
Logcat:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: __, PID: _
a.a
at ___.overview.dashboard.m.a(Unknown Source)
at ___.overview.dashboard.c.a(Unknown Source)
at android.support.v7.widget.RecyclerView$a.a(Unknown Source)
at android.support.v7.widget.RecyclerView$a.b(Unknown Source)
at android.support.v7.widget.RecyclerView$p.a(Unknown Source)
at android.support.v7.widget.RecyclerView$p.a(Unknown Source)
at android.support.v7.widget.RecyclerView$p.a(Unknown Source)
at android.support.v7.widget.RecyclerView$p.c(Unknown Source)
at android.support.v7.widget.LinearLayoutManager$c.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.c(Unknown Source)
at android.support.v7.widget.RecyclerView.N(Unknown Source)
at android.support.v7.widget.RecyclerView.q(Unknown Source)
at android.support.v7.widget.RecyclerView.onLayout(Unknown Source)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.support.constraint.ConstraintLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.support.constraint.ConstraintLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:887)
at android.view.View.layout(View.java:18798)
at android.view.ViewGroup.layout(ViewGroup.java:5951)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2648)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2364)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1515)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7091)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
at android.view.Choreographer.doCallbacks(Choreographer.java:702)
at android.view.Choreographer.doFrame(Choreographer.java:638)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
as @laalto said, there's a stacktrace that can be helpful
Putting this in my proguard file:
-keepattributes SourceFile,LineNumberTable
helped me find where the error was. This shows you the original classnames and linenumbers in the stacktrace. I'm still not sure why the error doesn't occur for debug mode, but at least I was able to solve it. Thanks again!