Android app crashes when launched in debug mode
For me, it occurred when I have a breakpoint in a nested function. In my case, it was within Runnable.run() {}
. Not sure if it happens in other nested functions.
Example:
public class TouchEvent {
public boolean HandleEvent(MotionEvent Event) {
new Runnable() { @Override public void run() {
int i=5;
i++;
}};
}
}
If there is a breakpoint on any line inside the run() func, it crashes with the error A/art: art/runtime/jdwp/jdwp_event.cc:661] Check failed: Thread::Current() != GetDebugThread() (Thread::Current()=0x########, GetDebugThread()=0x########) Expected event thread
.
This error occurs the first time the class is encountered, NOT when the breakpoint is hit. So it occurred for me when I stepped into a line that had new TouchEvent();
, before any of the TouchEvent's code was run (before the constructor).
The solution is to remove the break point (and put it elsewhere).
Edit:
Forgot to mention, it seems to be tied to API25, but has been reported for API26 and API27 too.
Edit:
Another solution is to disabled Instant Run, but please give @toobsco42 credit for that below.
Application crashes when i try to debug
The root cause of the issue is not clear, but I suspect it that it might be due to Instant run stored files.
So try disabling the instant run and disconnect the device, uninstall the app in the device and now try debugging it.
Hope it works.
To be more precise to turn off instant run in android studio:
1) Go to File-> Settings -> Search for instant run and uncheck it.
App Crashes in release but works fine in Debug mode
I guess, that if your DAO (f.e. Room) uses reflection, when you build release apk with minifyEnable=true
, your DAO can't find something. Try to check your proguard.
UPD
Yes, you have problem with obfuscation. 'java.lang.String com.biocare.database.n.b'
this 'n.b'
means that you had right path before obfuscation, but after obfuscation path was changed to values 'n' and 'b'. You should add this files (I don't know certain files, because I don't know your code) in proguard exclude list.
You can read more in proguard documentation. This can be useful too
How do I debug an Android app that crashes only in Release Mode
The answer was to set Additional supported encodings
to West
in the Android Options
screen under Project Properties
. It doesn't seem related but I was trying every possible combination and this finally worked.
Related Topics
How to Downgrade Android Emulator
Setonitemclicklistener on Custom Listview
Reading SQLite File from Asset Folder
Parse JSON Array Without Key in Android
Facebook - "Cannot Query Users by Their Username" Solution
Launch Activities from Different Package
Send Data Back to the Script Which Started the Activity via Adb Shell Am Start
Ics Android Enable Gps Programmatically
Get Context of Popupmenu Like Contextmenu
Realmchangelistener Does Not Get Called When Realm Gets Updated in Notificationlistenerservice
How Do Mpandroidchart Renderers Work and How to Write a Custom Renderer
How to Add to My Android Application a Button Than Do Like to a Facebook Page
Activity Declaration in Androidmanifest.Xml
Android Http Connection Exception
How to Share Same Data Between Multiple Activities
First Launch Take Long Time (Classloader Referenced Unknown Path)
How to Dismiss a Progress Bar Even If There Is No View to Populate in the Firebaselistadapter