android debugger does not stop at breakpoints - android

I am seeing debug statements in the console but the debugger does not stop on any breakpoints. I tried clearing all breakpoints and adding them back in. Not sure how this can happen but it is.

Solution that worked for me:
Simply uninstall the app from the device (manually on the device) and try debugging again(!)

If you use Android studio, click debug app instead of run app:

According to this answer, Inside build.gradle for your app module, disable minifyEnable for your build variant and change it to false. Then, it should be:
minifyEnabled false
othewise you will see Line number not available in class xxxx when you hover over breakpoint markers and they will be looked with a cross on them

Have you set the debuggable flag in the AndroidManifest?
If you miss that, do so by adding android:debuggable="true" in the application tag.
It should look like that in the end:
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="true">

In my case, click the "Attach debugger to Android process"
And it will shows a window said "Choose Process"
Select the device you are using, and select the project that you want to debug. And it works.
Sometimes the debugger need to re-attach to the devices when you open the debugger at the first time.

For Android Studio:
Check if the option Mute Breakpoints is enabled by mistake. The icon looks like this:
For Eclipse:
Check if the option "Skip All Breakpoints" is enabled by mistake. It is the last icon on the following toolbar

Did you do "Debug As --> Android Application" instead of "Run As"?
Only if you do "Debug As", eclipse will stop at breakpoints.

I had the same problem.
Go to build.gradle.
You must change this code if you have one.
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
The debug section should look like this:
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
I hope your problem is solved

if you have added some build type in build.gradle check to have debuggable true
buildTypes {
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

In my case, the app created a service with a different process with android:process=":service" in the AndroidManifest. So I was setting breakpoints in the service process code while the debugger is automatically attached to the main app process. Pretty stupid of me but it might help someone else.
You attach to the service process with Run > Attach Debugger To Android Process and choose the service process. You might need to add android.os.Debug.waitForDebugger(); to your service process code if you can't attach in time manually.
As far as I know, there's no way to automatically tell Android Studio or IntelliJ to attach to a different process before running.

i had this problem i clean buildTypes part of build.gradle
and try age so it work me.

If you are finding this issue while using the Flutter plugin, you can try updating the plugin to version >65.1.3 as specified in this article

None of the valid answers above worked for me. In my case there was another app still in the background that I had launched some time earlier via Android Studio. So not the same App/PackageId, but another. After closing that app I got hits on breakpoints via wifi debugging.

I had the same issue and resolved it by increasing the debugger timeout values.
The emulator is slow as a dog on my Dev box and that is what prevented the debugger to catch and stop on breakpoints.
I changed the timeout values respectively from 3000 to 10000 and 20000 to 60000 and all is fine now.
V.

Related

Android Profiler: No debuggable processes

It can find my device, but without any debuggable process. It's not the first time this problem occurred. But it still worked yesterday, I used profiler to observe my app's memory info. And when I try to debug my app, the process is debuggable. I tried all solutions just like restart Android Studio, none worked. Does anyone know why?
Works for me:
In build.gradle(:app) -> find "buildTypes" -> to "debug" section -> set it to "true" -> done
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
debuggable true
}
}
Mabe you can Close the AndroidStudio.And then restart the adb service.try again.
Keep your application installed is a Debug mode.
if is done,it will be work. I tried.
Since running apps on an emulator is slow, sometimes you may have more than one instance of your app on the emulator which will cause a problem. Just delete the existing emulator and create a new one, or you can instead just wipe the data on an existing emulator:

Flutter google map on release mode not work

hi to all flutter developer
my question: when I use flutter google map and when I build final and release app for android the map is not working
how I can fix this problem
please look at below image
Problem resolved, I must enter the SHA-1 when i creating API key
You have to write flutter command screen 'flutter upgrade'. Maybe it help you to solve your issue.
After a very long search and mainly thanks to the help of Ruslanbek0809 I solved this problem at last.
In android/app/build.gradle I added:
shrinkResources false and minifyEnabled false to the buildTypes
buildTypes {
release {
signingConfig signingConfigs.release
shrinkResources false
minifyEnabled false
}
}
And a miracle happened

Android Release build can be attached

I recently find my Android Release version can be attached through Android Studio and all logs are available to be seen as well, even though I'm sure that AndroidManifest.xml file doesn't contain "android:debuggable=true" and app's build.gradle file specified that
buildTypes {
...
release {
...
debuggable false
...
}
...
}
Do you guys have any good idea to avoid this?
You can only keep like this code below:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
hopefully works it.
Logs are nothing to do with debuggable true.
The option debuggale is to making your application debuggable in release mode, so you can attach debugger even on your release build by default it is false.
If you are using Log class and printing any log it will always display until and unless you put the check before logging them.
What you can do is put a check before every log is Build.Debug == true then print the log.
Or you can use open source library for this work like this one which provide the control of logging based on your configuration.
Or you can find a more helpful answer here.

Android Images are not displayed after release build or if i instant run turn off

I am getting images id from drawable-hdpi at run time using getIdentifier method using following code
mContext.getResources().getIdentifier(mContext.getPackageName() + ":drawable/" + mCur.getString(mCur.getColumnIndex(Constant.COLUMN_IMAGE_DRAWABLE)), null, null)
i also tried following ways
mContext.getResources().getIdentifier(mCur.getString(mCur.getColumnIndex(Constant.COLUMN_IMAGE_DRAWABLE))+"", "drawable", mContext.getPackageName());
and set image resource using following code
imgPosotion.setImageResource(item.getDrawable());
both work when i turn on instant run from android studio but unfortunately none of them work when i am turn off instant run feature from android studio.
I am using Proguard at debug as well as release time using following code
release {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Observed scenario
Image are not showing. Code run perfect and showing images when run with instant run.
i make release build and then decompile it, i observed that images(.png extension) are there in res/drawable-hdpi folder but sizes are converted into 1*1 dimension(67byte) and when i tried to open just a dot are visible and when i tried to open jpg(converted to 0byte size) files they are not opened.
Expected scenario
Image must be visible
Action taken to solved
Make the image size small
convert images into from .png to jpg
I stuck to this problem so please help me. Appreciate, if anyone can help to troubleshoot.
nobody takes this question seriously but after do lots of type stuff i got the solution. Actually problem was with proguard, i don't known why but it works after set false to shrinkResources
release {
..
minifyEnabled true
shrinkResources false
}
It`s the bad practce, you should use official google strategy as described here https://developer.android.com/studio/build/shrink-code#keep-resources
release {
..
minifyEnabled true
shrinkResources false
}
worked fr me

Enable LogCat on Release Build in Android Studio

By default, when I change Build Variants to release I don't get any Logs on the logcat, but I do need to read release logs of my app, how can I enable this?
Add android:debuggable="true" (default is false) to your Manifest inside the <application> tag.
From the docs:
android:debuggable
Whether or not the application can be debugged,
even when running on a device in user mode — "true" if it can be, and
"false" if not.
respectively
You can disable debugging by removing the android:debuggable attribute
from the tag in your manifest file, or by setting the
android:debuggable attribute to false in your manifest file.
Edit
You may need to add the following to your build.gradle file inside the android{...} tag:
lintOptions {
checkReleaseBuilds false
}
And as a side-note: Right on the device the Logs are always written, no matter if your application's debuggable is set to false or true. But via the LogCat in Android Studio it's only possible if debuggable is set to true. (Just tested this)
You should add
android {
buildTypes {
release {
debuggable true
In this case you can use Log. or System.out.println and see logs.
If you cannot run release version (app is disabled), and error is shown: "apk is not signed. Please configure the signing information for the selected flavor using the Project Structure dialog", see app-release-unsigned.apk is not signed.
I do not like the other solution because then you are not testing how the App really is deployed.
A better solution is to open the Android Device Monitor where you can see the logs even when in release configuration with debuggable=false.
Find it here:
Tools -> Android -> Android Device Monitor
Update:
Android Device Monitor was removed in Android Studio 3.2. However, it is still present in SDK, and you can use it to see the logs (it is located in $ANDROID_SDK/tools/)
debuggable true in build.gradle works well, except that BuildConfig.DEBUG is also going to be true. This might be a problem if your app relies on BuildConfig.DEBUG to do something only when it's a debug build.
In such a case, try Log.wtf(BuildConfig.APPLICATION_ID, "something went wrong"), which will print to logcat even if it's a release build.
This approach will obviously help you to get logs while testing the production build. But be careful while uploading your app to Google Play Store, Toggle debuggable to false before uploading to production.
buildTypes {
debug {
manifestPlaceholders = [crashlyticsCollectionEnabled: "false"]
}
release {
manifestPlaceholders = [crashlyticsCollectionEnabled: "false"]
lintOptions {
checkReleaseBuilds false
abortOnError false
}
shrinkResources true
minifyEnabled true
debuggable true
signingConfig signingConfigs.productionrelease
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
set crashlyticsCollectionEnabled to false to avoid your crashes to report to Google Play-Store while debugging.

Categories

Resources