Android Profiling is unavailable for the selected process, but advanced profiling is enabled
Asked Answered
R

7

15

I am developing an Android app with multiple modules. The app uses ProGuard, compileSdkVersion is set to 27 in all modules, and when I tried to enable Advanced Profiling I continue to get a message saying "Advanced profiling is unavailable for the selected process".

Solutions I've tried after searching other questions about the topic:

  1. Enable Advanced Profiling (obviously) for the app as well as the default Run Configurations
  2. Disable ProGuard in all modules using minifyEnabled false
  3. Update Studio version to 3.1.3 and Gradle to 4.4
  4. Rebuild project after the above changes

Am I missing something? Is there anything else I can do to enable Advanced Profiling?

Radiotelegraphy answered 12/6, 2018 at 9:27 Comment(0)
S
10

I had the same problem and the solution was easy, in my case: set debuggable true in file build.gradle for the selected Build Variant.

Silvanus answered 19/6, 2018 at 10:54 Comment(0)
O
6

If you are running API level < 26, enable the Profiler in Run -> Edit Configurations. From the list, choose your module. On the right hand side of the window, click Profiling. Enable the checkbox Enable advanced profiling.

Ockham answered 2/10, 2019 at 9:36 Comment(2)
When I enabled this, I get following error when I try to run the app Execution failed for task ':app:transformClassesWithProfilers-transformForStagingDebug'.? How to fix this?Bravar
Hey @Bravar you got any solution so far? it's been 3 months. I saw your comment on on other answer as well but no where have they mentioned how to fix it, they just mention how to disable advanced profiling which is not what we need.Mart
M
3

Had the same problem with my phone Android api level 28: "Android Profiling is unavailable for the selected process".

Solution 1.

The following steps helped me temporarely - then after rebuild the problem appeared again:

  1. clean the project
  2. Removed .idea folder
  3. Restarted the project
  4. Now profiler works ,e.g., I can select Network Profiler range

Solution 2.

Use emulator api level 29. Advanced profiling always works fine for me there.

What didn't help me:

  • debuggable true (already was)
  • Edit Configuration > Profiling > enable .. (already was)

And such Android Studio tricks drive me crazy.

Matteson answered 16/7, 2020 at 10:0 Comment(1)
Solution 1 worked for me too [2]. Any other solution that I tried worked. Android Api 25.Indisposition
A
2

In your build.gradle file turn on debuggable flag (debuggable true).

For eg :

buildTypes {
        debug {
            debuggable true
            buildConfigField "Boolean", "DEBUG_MODE", "true"
        }
    }
Arbe answered 1/6, 2020 at 1:53 Comment(0)
T
2

I feel a bit of shame posting this answer, but my problem was I wasn't launching the application from Android Studio. I was launching the app from the device's app drawer.

Launching the application from Android Studio allowed me to debug the network traffic.

Transmigrate answered 25/5, 2021 at 19:55 Comment(2)
I really appreciate you posting this - that was exactly the problem I was experiencing just now. I have NEVER been able to figure out why sometimes it can attach and sometimes it can't. Thank you!Dennis
@Dennis Glad I wasn't the only one ;-PTransmigrate
M
1

Advanced profiling is unavailable when the profilers are unable to attach an agent to the device to application to get detailed information.

Setting the "debuggable" flag in the manifest only helps if the profilers are unable to "see" the application.

The most common reasons advanced profiling is disabled are either you are on a device that does not support "run as" (Most newer devices should). Or as you have mentioned "advanced profiling" is not enabled.

If you feel this is a bug in the profilers please file a bug @ https://issuetracker.google.com/issues/new?component=192708&template=840533 and be sure to include both logcat logs, as well as Android Studio logs in the bug.

Margotmargrave answered 21/7, 2020 at 22:4 Comment(0)
S
0

Try doing Menu > Run > Edit Configuration... > Profiling then mark checkbox Enable advanced profiling and then re-running/building.

OR

If it doesn't work, try Clean Project then Rebuild Project

Slog answered 9/11, 2020 at 11:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.