38

I am not able to debug an app on my device (Asus Zenphone 2) after I updated android studio to 2.0. I keep seeing below message in debug tab right after I click on debug icon in Android studio.

Message in debug tab in Android Studio UI

---------------------------------------------------------------
Waiting for application to come online: packagename
Waiting for application to come online: packagename
Waiting for application to come online: packagename
Waiting for application to come online: packagename

I keep seeing Alert Dialog with the title "Waiting for Debugger" and Force close button all the time.

I searched but it seems only two results from google for that message.

I restarted Android studio, checked developer settings on phone...

Have anyone faced with this issue. Please help me. I cannot run the emulator, because my mac will be too lag. Thank you in advance.

t4nhpt
  • 5,074
  • 3
  • 31
  • 41
  • Are you able to run the app, without the debugger? Is the updated app getting installed, but then just cannot be run by the IDE? – CommonsWare Apr 19 '16 at 16:09
  • 1
    Yes, I can run app without the debugger. – t4nhpt Apr 19 '16 at 16:11
  • 1
    OK, so it's not something tied to the MAC address registration stuff. You might try disabling Instant Run and see if that helps. You will find that in Settings > Build, Execution, Deployment > Instant Run in Android Studio 2.0. – CommonsWare Apr 19 '16 at 16:14
  • Just disabled Instant Run and there is no luck. I afraid that the phone block app for debugging. When updating Android Studio, I also try to configure something with CM Applock. Then I disable all but still got that error. – t4nhpt Apr 19 '16 at 16:22
  • It is strange that this block only occurred when you upgraded to Android Studio 2.0, though. However, I am out of ideas as to what the problem might be. – CommonsWare Apr 19 '16 at 16:24

12 Answers12

28

The problem is that after installing and starting to launch the app, that debugger client that AndroidStudio starts is unable to connect to the debugger server on the device. This can have many causes, see this answer and the other answer shown on this page and see if one solves the problem for you

To help figure out the problem, look at the 'Console' tab of the 'Debugger' window in AS. One of the first few lines should look like this:

$ adb shell am start -n "com.acme.audtest/com.acme.AudTest" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D

Cut and paste that line into a command prompt, REMOVE THE '-D', and execute it. It your app ('AudTest') comes up without error, the problem is in AS, is communication to the device, or the configuration of the device. If the app doesn't start, it is in the .apk. (Not the complete solution, but starts to point you in the right direction -- for which of the solutions below applies to your situation.)

Choice

First I select the second option, and it worked fine. But then don't know why I change to select first option. So, the debugger shows the message Waiting for application to come online forever. And I did not notice that, just thought another app prevent me debug or that was an issue with Android Studio 2.0.

So, just check to second option will solve my issue. Thank all.

Ribo
  • 2,923
  • 1
  • 25
  • 32
t4nhpt
  • 5,074
  • 3
  • 31
  • 41
20

Restarting Android Studios (2.1.1) resolved this for me.

running-codebase
  • 928
  • 1
  • 11
  • 17
14

There are two possibilities:

1.USB Debugging off :

  • Start Developer Option of your devices
  • Switch On USB Debugging

2.In Android-Studio : File -> Invalidate Caches / Restart

anyone can be useful for you.Try it

Kshama Singh
  • 184
  • 1
  • 3
9

The correct answer is close your Android Device Manager. None of these suggestions worked for me till I closed it.

JustAGuy
  • 3,773
  • 8
  • 33
  • 49
4

I had to remove the parameter

 android:exported = "false"

from the main activity.

Alberto M
  • 1,115
  • 1
  • 12
  • 33
4

Nothing worked for me except one solution...

Clearing the Intellij IDEA (Android Studio) .idea directory which contains configuration information worked for me:

Exit Android Studio Navigate to the project you are trying to debug Backup any files inside .idea that you modified (if your project checks any of these into VCS) Delete .idea directory Open the project in Android Studio

Ashutosh
  • 166
  • 8
2

if you get this problem on the emulator, running adb reconnect worked for me. there is a similar command for devices adb reconnect device

Samer
  • 321
  • 3
  • 7
1

**

This answer might help for those Who have successfully connected their device along netbeans NB Android but on debug there's no application being appear on device.

**

Ok so solution is check your android device version in mobile setting click on about device at last: you will know your android version there.

Now choose the same version for your netbeans android project.

Right click on project name click on properties and then change target with same as your android device.

(In my case android version was 4.4.2 so I selected the same for my project target)

Before to go ahead click on service tab next to project tab in netbeans then right click on Android device and click on restart ADB.

Finally you need to right click on project again and click on clear and build.

Now you can run with hope to get result.

A.Aleem11
  • 1,460
  • 12
  • 12
0

I just wanted to share my experience as I had the same error and there was no way to solve it using all the solutions you guys posted. I even deleted several times my virtual device, no way to make it work again.

In my App I have a custom permission com.example.CUSTOM_PERMISSION and I wanted to use it to protect my Main Activty from a confused deputy attack.

    <permission android:name="com.example.CUSTOM_PERMISSION"
            android:label="@string/permlab_deadlyActivity"
            android:description="@string/permdesc_deadlyActivity"
            android:permissionGroup="android.permission-group.COST_MONEY"
            android:protectionLevel="dangerous" />

. . .

    <activity
            android:permission="com.example.CUSTOM_PERMISSION"
            android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

Somehow that property android:permission was preventing my app to install and run on the virtual device, even though it could be compiled and build with Gradle successfully. Just after removing it, everything is fine again I am not sure the app is protected this way, I'm building another test app to try performing a confuse deputy and see if the declaration of the custom is just enough.

Hope this can help somebody that was getting mad like me!

0

I had this problem in the Android emulator, and it was solved by going to Tools->AVD Manager, selecting the device, right click "Cold Boot Now".

xpusostomos
  • 739
  • 6
  • 10
0

The solution which helped me is to click on attach the debugger to android Process and set debugger to java.

0

Just throwing my experience in as this just started happening. With regards to all these answers, I tried a few of them and none seemed to work. So I started from scratch:

Initial setup: - USB Debugging ENABLED - Always prompt when connecting to USB (I usually only connect in charge mode) - Allow ADB debugging in charge only mode ENABLED - Wait for debugger DISABLED - Verify apps over USB ENABLED

The steps I took to get debugging back:

  • Close down Android Studio - I didn't go so far as to delete the .idea folder as discussed, but I'm sure it couldn't hurt.
  • DISABLE USB Debugging
  • Revoke USB debugging authorizations
  • Reconnect Device
$ adb devices
> <Device Id> unauthorized
  • ENABLED USB Debugging
  • Reconnect Device
  • When prompted select ALLOW (I clicked always allow)
$ adb devices
> <Device Id> device

Open Android Studio and hit debug - Application started successfully, I was still getting 5-6 of these messages but then it worked:

$ adb shell am start -n "com.exampleapp/com.exampleapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Connecting to com.exampleapp
Connected to the target VM, address: 'localhost:8600', transport: 'socket'

React Native

As a side note - this happens every so often, I'm not sure whether it's from switching back and forth between running from react-native run-android or debugging in Android Studio, but regardless I've had to do this a couple times (finally decided to document).

Also remember

$ adb reverse tcp:8081 tcp:8081

and to start the packager when debugging (I tend to forget).

kendavidson
  • 1,245
  • 1
  • 8
  • 16