When I try to use profiler in Android Studio, I am able to see my connected device but I am getting "No debuggable process" in the Profiler. Can someone please help me why i am getting "No debuggable process".
You can try any/all of the following:
Invalidating cache and restarting your Android Studio: To do this, from the menu bar select File > Invalidate Caches / Restart
Restart your phone
Disable and enable USB debugging
Restart your computer
You can also check if your app is marked as debuggable in build.gradle. To do this, just go to your app-level build.gradle file, and under buildTypes check if the debuggable property is set to false, if yes change it to true. Something like:
buildTypes{
release {
debuggable false
}
debug {
debuggable false
}
}
Alternatively, to do the same you can also do it the old way by adding the following line to your Manifest file under the Application tag:
android:debuggable="true"
This should fix it.
Related
I'm looking for a way to tell if my app is running under the debugger or running "normally", under Android Studio..
These two cases are
1. Run the app by clicking the "Run app" button (green arrow)
2. Run the app by clicking the "Debug app" button (gear icon)
I would like to output more verbose diagnostics (using Log.*) while debugging.
I tried checking BuildConfig.DEBUG but that is TRUE in either case. I suspect this is because Android Studio signs the app with the Debug Certificate in both cases.
Does anyone know how to distinguish these two cases at runtime?
typically one would check for BuildConfig.DEBUG (or a boolean variable holding it) and then log:
if(BuildConfig.DEBUG) {Log.d("SomeActivity", "debug message");}
see the documentation... most relevant for debugging is build-config debuggable true/false.
the run button does not start the debugger; no matter the build-config (it just skips all breakpoints).
in multi-module projects, one should check with:
(getContext().getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0
to tell them apart, two build types need to be configured:
android {
...
buildTypes {
debug {
...
renderscriptDebuggable true
jniDebuggable true
debuggable true
}
release {
...
renderscriptDebuggable false
jniDebuggable false
debuggable false
}
}
}
and to precisely answer the question, there even is one method called isDebuggerConnected(), which would always return false when hitting the run button (no matter the build-config).
"Run app"
This will install the application into your device/emulator
"Debug app"
This will enable you to debug function by placing the break points into your code.
which means you will be able to stop execution of code at that point and debug it line by line. To know more about debugging in android see this
Both the application are debug applications.
To know more about build type please read this
I am just switching from Eclipse to Android Studio and found this weird behavior. When I add a breakpoint in the first line of a method, I cannot see the parameter values. The only thing I can see then is the this reference. I either have to make one debug step or set the breakpoint to a line after the first one to see the parameter values.
Anyone else has this problem or knows what's going wrong here?
Try turning off your jacoco test coverage off for the debug build in your build.gradle file:
debug {
...
testCoverageEnabled false
}
This completely fixed the issue for me where upgrading the gradle plugin did not.
A good solution until AOSP Issue #123771 is solved, is to use the snippet provided by Stuart in the comments section:
buildTypes {
debug {
[...]
testCoverageEnabled true
}
release {
[...]
}
debuggable.initWith(buildTypes.debug)
debuggable {
testCoverageEnabled false
}
}
This way you can both keep your test coverage reports in your debug build and have a way of stepping through code seeing your local variables.
I don't have in my gradle file:
debug {
...
testCoverageEnabled true
}
but had the same issue on Android Studio 2.2. Solution that helped me to resolve issue:
Disable Instant Run in IDEA Settings.
Re-build project.
Enable Instant Run.
The solution provided by Google here is to upgrade the Android Studio Gradle plugin to v1.0.1
If your build uses the jack toolchain this can be the source of the problem. In my case, disabling jack solves the problem:
buildTypes {
...
debug {
jackOptions {
enabled false
}
}
}
Note: 1.8 source compatibility requires jack!
I got sick of toggling testCoverageEnabled when I wanted to debug so set up a project property to disable it when run from Android Studio, but default to enabled when run from command line with no options such as on a build box.
// Default to true, set -PtestCoverageEnabled=false in IDE compiler command-line options
def isTestCoverageEnabled = { ->
def enabled = project.hasProperty('testCoverageEnabled') ? testCoverageEnabled.toBoolean() : true
println "testCoverageEnabled = " + (enabled ? "true" : "false")
return enabled
}
android {
buildTypes {
debug {
testCoverageEnabled isTestCoverageEnabled()
}
}
}
To set the property in the IDE add the command-line option -PtestCoverageEnabled=false
Android Studio -> Preferences -> Build, Execution, Deployment -> Compiler -> Command-line Options
I ran into this issue when trying to debug an app that was previously installed using an APK and not from Android Studio itself. Fixed it by uninstalling the app and re-run the debug.
Following configuration worked for me for buildType release.
buildTypes {
release{
testCoverageEnabled = false
debuggable true
minifyEnabled false
shrinkResources false
}
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.
When I'm trying to debug application using android studio, I set some breakpoints in the IDE and after starting the debugger I've got an info on every single one breakpoint (in the baloon):
Warning : No executable code found at line ...
It looks like the message appears when the application reaches first BP.
Just to be clear - I have executable code in those lines like String s = "asd";
In my case a Build - Clean Project did help.
set the minifyEnabled to false:
From the project section select the project
Right click on project and click open module settings
select the module you are running and from Build Type set the Minify Enabled to false
Try to insert the next snippet code into the android{} block on the app build.gradle file:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false //<---- THIS FIX THE PROBLEM
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'pro
guard-rules.pro'
}
}
Do you debug on device or on emulator? If device then try to switch back to Dalvik from ART
The first line breakpoint works only
Responding to user3167086's post -
I had the same problem with the breakpoints not working in the middle of a method. One line of code was fine, and the break point icon had a "check mark" in it, but the next point had an "x" in the icon and gave the warring of "no executable code". I checked the Project Structure and the Build Type had already defaulted to "false", but I set it to false again and clicked OK.
For those using Android Studio 1.5 like I am, the complete procedure - using the main menu - is to
select File -> Project Structure.
Then select your "App" module on the left, and then the "Build Types" tab across the top.
Make sure you have "Debug" selected and not "release" on the left (you should see this at the top of the right hand column too) and then set Minify Enabled to FALSE.
Make sure that you use a "Debug" build variant - otherwise breakpoints don't work.
I saw this error message in a pop-up over the dreaded breakpoint with an X in it, in Android Studio's "stable" version 2.1.2 (Gradle: 2.10, Android Plugin: 2.1.2), and the fix was to simply hit the red 'stop' button on the current run session in Android Studio.
I have no idea how the current run session could interfere with setting a break point in source (I have everything under 'Instant Run' unchecked), but this worked for some reason.
For the future:
In my case ALL lines of code were unavailable for debugger. Solution for my problem was disabling jack to avoid creation of intermediate code.
These lines in my gradle.build were to blame:
defaultConfig {
jackOptions {
enabled true
}
}
I turned jack options on several months earlier and then switched back to Java7 forgetting about how my application works. No suprisde Android Studio couldn't find matching code.
I hope it will help.
I have Android debuggable set to false, yet the condition true. What is wrong here?
Application:
//debugable false or true, nothing changes
if ((applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
Log.d(TAG, "debugable");
}
Manifest:
<application android:debuggable="false" ...
The answer to this very question is already given on SO.
See Android 'debuggable' default value.
.
Declaring your application as "debuggable" in your Android Manifest enables you to debug your Android applications on an Android-powered device , just as you would on the emulator
When using Eclipse, running your app directly from the Eclipse IDE automatically enables debugging.
If you manually enable debugging in the manifest file, be sure to disable it before you build for release (your published application should usually not be debuggable).
The debuggable flag in the manifest gets changed automatically, you can remove it completely, which is also recommended by Google.
If you debug your application, the flag is true. If you export the applicaton, the flag is false.