问题
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.
回答1:
I found the issue. See this image below:
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.
回答2:
Restarting Android Studios (2.1.1) resolved this for me.
回答3:
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
回答4:
The correct answer is close your Android Device Manager. None of these suggestions worked for me till I closed it.
回答5:
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
回答6:
I had to remove the parameter
android:exported = "false"
from the main activity.
回答7:
if you get this problem on the emulator, running adb reconnect
worked for me. there is a similar command for devices adb reconnect device
回答8:
**
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.
回答9:
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!
回答10:
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".
回答11:
The solution which helped me is to click on attach the debugger to android Process and set debugger to java.
回答12:
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).
来源:https://stackoverflow.com/questions/36723813/not-able-to-debug-app-on-android-device-android-studio-2-0