Android Emulator keep showing allow USB debugging prompt - android

I just installed Android Studio Bumblebee (2021.1.1 Patch 2)
But when I try to run my emulator, I got allow USB debugging prompt that always showed up even after I press allow, check the always allow option, or even cancel it.
I already tried to restart my adb server and remove and create a new emulator, wipe the data and try to cold boot it, but the issue persists.
Does anyone know what is the root cause of this issue and how to solve it?
I can still develop using real device but I do want to know if this issue able to be resolved.
Emulator: Google Pixel 3 API 30

If the "Allow USB debugging" message is shown again and again then this is usually a problem of the host, not of the Android device.
You should reset the Android ADB authentication key by deleting it and then restarting ADB. A new authentication key (pair) will be generated which will hopefully work.
To do so delete the files adbkey and adbkey.pub in the folder ~/.android/.
Then execute adb kill-server and finally restart adb by executing adb start-server.
Note that this will reset USB ADB authorization of all devices you had connected to that PC/user account.

I had the same issue and and manage to fix it by turning off and back on usb debugging in emulator developer options. Still don't know what caused the issue in the first place.

I able to resolve this issue by creating new AVD with X86_64 system image.

Related

Android device is not responding

I used Unity 2019.
When I connect my android devices (3 devices, tablet included) to Unity and try to run and build any apk, devices are recongized in Unity but the compilation process fails. lt's, writtren :Android device 52000... is not responding
I had this problem with my new phone, which was occurring even after enabling USB debugging and authorizing the PC through the phone. I ended up finding the answer in here Unity's documentation:
Run the adb devices command from the platform-tools directory of your
Android SDK installation and check the output.
If the output list is empty and you are using Windows, you may need to
install the driver for ADB devices. For more details, refer to the
Android SDK/NDK Setup documentation.
If the list contains entries with the unauthorized label, you may need
to authorize your computer on your device and give it permission to
debug it. Check the device’s screen for the corresponding dialog.
If the list contains your device with the device label, build your
Project in Unity again.
I resolve the problem.
In USB connection mode, on my phone, there are 4 options:
Transfer files
transfer images
Connect a MIDI device
Charge this phone.
I ONLY changed the connection mode to TRANSFER IMAGES.
After that, I received a prompt asking me the validate this connection mode. I did it and it works fine.
I resolved this issue, by changing the USB connection mode to Image Transfer(PTP) in my MI device
the problem is very clear. The compilation is successful, which means there is nothing wrong with your code. And the error message in the dialog box is clearly saying that
Make sure USB debugging has been enabled
So, to solve this simply follow the steps below -
Navigate to Settings > About Phone > Scroll to bottom > Tap Build number several times
Go back and now access the Developer options menu, check 'USB debugging' and click 'OK' on the prompt
You can also checkout this link
On android device, when prompted for "Allow USB debugging?", selecting "Always allow from this computer" checkbox solved the problem for me.
In order for my phone to show up the "Allow USB debugging?" dialog, I revoked the USB debugging authorisations from my android device and then ran "adb devices".
Also once I did this, unity was showing my device name instead of just device id.
Here's what worked for me.
Windows key type cmd
cd C:\Users\[name]\AppData\Local\Android\Sdk\platform-tools
adb kill-server
adb start-server

Android emulator not able to access the internet

I know that similar questions have been asked before, but my problem is new only after installing Android Studio 2.3, the latest version in March 2017. I have several years experience developing Android applications, and I have never encountered this problem before. After upgrading to version 2.3 of Android Studio, my emulator is no longer able to access the internet. I even uninstalled/reinstalled Android Studio 2.3 from scratch and created a new emulator, and I am still getting the same error. This is not an app problem. I can't even access the internet from Chrome, and I wasn't having this problem last week. The message that I get says that the server DNS address could not be found -- DNS_PROBE_FINISHED_BAD_CONFIG. The only thing that has changed on my computer in the last week is the new version of Android plus possibly updates to Windows 10. And yes, my computer has access to the internet. Below is an image of my emulator when I try to use Chrome to search for "Google".
1st try "Cold booting" the emulator as suggested here.
If cold booting doesn't work, try changing the DNS address of your network to 8.8.8.8 (Google's DNS) or another of your preference:
MacOSX:
Open "System Preferences"
Click on "Network"
Select the network which your computer is connected and click on "Advanced"
Select "DNS", Select the "+" button, type "8.8.8.8" (Google's DNS) or if you prefer OpenDNS, "208.67.222.222"
Select "Ok" and "Apply"
Windows & Linux:
https://developers.google.com/speed/public-dns/docs/using
After that close the emulator and start it again.
After trying many of these solutions, I was going to just delete my current AVD and make it again, but when I clicked the down arrow on the AVD, I noticed "Cold Boot Now".
On a whim I tried that. Lo and behold my emulator has internet connectivity again!
Command-line approach
In case you start Emulator through command, pass -no-snapshot-load option, like:
%ANDROID_HOME%/emulator/emulator.exe -netdelay none -netspeed full -no-snapshot-load -avd Pixel_2_API_28
Or for MacOSX:
$ANDROID_HOME/emulator/emulator -netdelay none -netspeed full -no-snapshot-load -avd Pixel_2_API_28
Note that you may need to change -avd Pixel_2_API_28 part (with your own Virtual-Device name).
Also, most tools use ANDROID_HOME environment-variable name, hence define that (if not already), but nowadays ANDROID_ROOT is yet another naming-option.
Decision (edit)
Ok, for those saying why not just wipe data and restart.
Do you reformat your PC every time you restart it? Wiping data on the emulator is just like doing a factory reset to a phone or reformatting your hard drive on your PC and reinstalling your OS. It is unnecessary unless the data is totally corrupt.
When you shut off the emulator and restart it, it is like putting your PC in hibernate or sleep mode. Memory is not wiped, it is saved.
Doing a cold boot is the same as rebooting your phone or rebooting your PC. It resets memory and lets things reload. This allows the network emulation to start with clean memory and connect properly.
So, don't wipe your data. Just cold boot. If it still doesn't work, then wipe, but save that as a last resort.
I found a temporary solution on an old Stack Overflow thread at Upgraded to SDK 2.3 - now no emulators have connectivity. Note that this thread talks about Android SDK 2.3, not Android Studio 2.3. The problem seems to be that the emulator can't find the DNS my computer is currently using, and the temporary workaround is to start the emulator from the command line and specify the DNS server. Whatever problem occurred back then must have reappeared in the latest version of Android Studio.
The temporary solution outlined below fixes the problem with the emulator accessing the internet. However, it does not fix the problem that occurs when trying to run Android Device Monitor. Doing so will still make the emulator go offline as described above.
Note that there are two files named "emulator.exe" in the sdk -- one under sdk\tools and another under sdk\emulator. Either might work below, but I use the one under sdk\emulator.
The first step is to find where the SDK is located. Assuming a user name of "jdoe" and a default installation of Android Studio on Windows, the SDK is most likely in
C:\Users\jdoe\AppData\Local\Android\sdk
The second step is to determine the name of the AVD (emulator) that you want to run. The command
C:\Users\jdoe\AppData\Local\Android\sdk\emulator\emulator.exe -list-avds
will show the names of your AVDs. On my computer, it shows only one, Nexus_5X_API_25.
To start the emulator from the command line with a specified DNS server, use something like the following:
C:\Users\jdoe\AppData\Local\Android\sdk\emulator\emulator.exe -avd Nexus_5X_API_25 -dns-server 8.8.8.8
In this case, 8.8.8.8 is a Google public domain name server.
The above commands can be shortened if you create appropriate environment variables and edit your PATH environment variable, but I recommend caution when doing so.
[UPDATE 2022] for Mac Users
For NOT Apple Silicon users
System Preferences
Network
WiFi > Select Advanced
From Advanced Choose DNS tab
Add DNS Server 8.8.8.8
Emulator must be restarted after DNS Server has been added (Thanks to #kapusch)
For Apple Silicon users
as per #bourdier-jonathan
You can fix the Silicon issue here:
Emulator appearing offline on M1 Mac after the last update of arm64-v8a
By replacing the AVD system images you have downloaded with the r02 images. Because It appears r03, r04, and r05 all don't work on m1
Updating my WIFI adapter to resolve DNS on 8.8.8.8 solved the issue for me. It started to happen after an Apple update which messed up the DNS address.
Simply open the AVD Manager and wipe the data of that emulator works for me.
Open Android emulator and go to the Extended Controls. Then go to the setting => proxy(Tab), uncheck "Use Android studio HTTP proxy setting" and click "Apply".
macOS: long Story short.. make sure your DNS settings 8.8.8.8 is the first in line, wipe your data and do a cold boot.
Reminder: the Android Emulator internet connection does not work if you turn on a VPN system on you computer.
I experienced this same issue after upgrade. Upon opening the Chrome browser in the emulator, google.com could no longer be reached.
I found a post on SO that suggested the problem was with the emulator trying to use a disconnected network adapter. For me the problem was occurring when I was connected to a LAN. Disabling the wireless LAN adapter fixed the issue.
To disable the adapter:
Navigate to Network connections
Find the adapter
Right click and choose disable
I've resolved wiping data from AVD Manager
This happend to me when the emulator froze and I had to kill the process. The signal icon always showed the small "x" as in the screenshot and no internet connection was successful.
The only thing that helped was uninstalling and reinstalling the emulator (not the AVD images)
In Android Studio:
Tools-> Android -> SDK Manager
Uncheck "Android Emulator" and let it uninstall then check again and let it install again.
I am also facing the same problem, but I am trying to solve the problem using various posts. Today I discovered this problem. Your computer configuration is most likely the problemm, not Android Studio and the Android Emulator.
The problem is coming from your Network setup. Just set the Primary DNS Server to 8.8.8.8, which will solve the problem.
I got a simple and permanent solution for this issue in windows.
Go to network and internet option->
click on Etherenet or wifi(for which you are connected) option ->
Click on change adapter option ->
Right click on the network for which you have connected.
A dialog box will be opened and just click on Internet protocal version (TCP/IPv4) option.
Another dialog box will be opened and there just neglect the first set about the IP address (Keep as it is set) and click radio button of Use the following DNS server addresses: and enter as 8.8.8.8 in Preferred DNS server: and 8.8.4.4 in Alternate DNS server:
Now you can open your emulator whenever and you will get internet in the android emulators.
For me the problem was caused when I took my laptop home without restarting the emulator. From what I have read, when the emulator starts up it reads your PC's DNS settings and uses them. When I was on my home network, my work DNS settings were failing.
So yeah. Just restarting the emulator solved my problem.
This was a problem for me last time the emulator updated itself and back then disabling other network adapters fixed it. Now it's cropped up again but the only adapter that is enabled is a single wifi one so I have nothing to disable.
The issue only reappeared after I updated via a prompt the emulator tools to 26.1.1. I uninstalled and reinstalled the emulator via the SDK Tools update tab and thankfully the only option when installing again right now is to install 26.0.3 (which seems to be working okay).
Moral of the story is to be very wary of emulator updates.
I faced this problem after i kept my emulator ON while going from my home to a cafe. "Cold Boot Now" fixed the issue.
After 10 days of trouble, I just deleted everything from C:\Android\.android\ and deleted all created AVDs. Now internet seems to work fine.
closing the emulator and reopening worked for me
OS
WINDOWS 10
Just goto AVD manager and Cold Boot Now worked for me
I can make it work after turn off and turn on the wifi on android config
Please go through the below link.
https://developer.android.com/studio/run/emulator-networking
Emulator open, click More ..., and then click Settings and Proxy. From here, you can define your own HTTP proxy settings.
Enter the hostname by following
Run > cmd > hostname
Finally, check the internet access inside the emulator by browsing in chrome or google.
Note: Often wipe data will clear the issue. Please follow all steps
I am on android studio 3.1 and it happened.
Solved it by restarting the adb server
$ adb kill-server
$ adb start-server
Hope it helps. Thank you
There was a problem for me too, by disabling the proxy in Android Studio settings, and run the emulator with "Cold Boot Now", the problem was resolved.
Solution for MacOS that does not use a custom DNS for your whole machine
Step 1
Locate the emulator executable Android Studio is using inside the Android SDK and rename it to emulator-original.
Mine is located /usr/local/share/android-sdk/emulator/emulator but it might vary based on individual setups.
Step 2
Add a new file called emulator in the place of the original file containing the following command (or using your DNS server of choice).
#!/bin/bash
$0-original "$#" -dns-server 8.8.8.8
Step 3
Make the new emulator file executable.
chmod +x emulator
Step 4
Restart the emulator using Android Studio.
if android browser can access internet
you can run emulator from terminal
by this command
go to SDK path then
$ /tools/emulator -avd
Nexus_5X_API_23 -netdelay none -netspeed full
it solve your internet problem...
I was having the same issue and i resolved with below steps:-
Go to emulator setting and then go to
setting->Proxy->Either configure it Manually or use Tick use Android Studio HTTP proxy simulator.
please vote, if this works for you
Try these steps once, they worked for me:
Disconnect your PC from the internet
Close the emulator while you are still disconnected
Again connect to the internet
Finally start your emulator again
Just recreating the emulator with another target API worked for me
Maybe you set a proxy for Android Studio and the proxy does not work. Try without proxy.

android: Failed to install .apk on device "device": timeout

A few days ago I started having troubles while trying to install a .apk on my Galaxy S2. I select my phone as the target, click OK and in the Console get the following error:
Failed to install AvatarRun.apk on device 'device number': timeout
Launch canceled!
Without changing anything in code and running again I can also get the error:
Failed to install AvatarRun.apk on device 'device number': device not
found com.android.ddmlib.InstallException: device not found Launch
canceled!
I have tried opening a command window and navigating to android-sdk\platform-tools and running:
adb kill-server adb start-server
This did not fix the issue.
This seems to just be a coincidence, but after failing many times I changed the minimum SDK in the Manifest from 10 to 7 and the .apk loaded on the next try, but has worked intermitently since and generates the same errors.
Can anyone suggest a method for finding what is causing this error?
After trying the fixes mentioned above, I ended up installing and reinstalling the Galaxy drivers. This didn't help. What eventually worked (so far) was to switch which USB port the Galaxy is plugged into. Once I did this everything was functioning as it should.
It may sound ridiculous, I tried all the ways suggested in Android error: Failed to install *.apk on device *: timeout
None of them works for me except unplugging the current cable and change for a new one.
There are various solutions:
Try changing the ADB connection timeout. The default is 5000; you should change it to 10000ms or so.
Window -> Preferences -> Android -> DDMS -> ADB Connection Timeout (ms)
Try to unplug and re-plug the cable. It seems that sometimes Eclipse loses the connection with Device. Sometimes you just need to plug into other USB port.
You might need to kill the ADB process and restart it.
adb kill-server and then
adb start-server
For me, the solution is to uninstall the old apk from the phone.
This problem often shows up if the computer is not fast enough. So,if you go to task manager you will see the performance. If you are watching video or running other programs at the same time while you are running your android application close other programs; at least during installing the app on device or emulator. You might even need to close internet browser.
You might need to update your computer to make it faster if you can.
Hope this helps someone:)

How can I make eclipse connect to Android emulator manually?

There are lots of times Eclipse can't connect to emulator that I turned on from AVD Manager, and just starts a new emulator by itself,( two emulators are the same ):((. How can I make eclipse find the emulator ?
some times restarting adb solves your problem
adb kill-server
adb start-server
for working easier in command line in windows, add the path of adb.exe to that Windows' path. For example add ";C:\Program Files\Android\android-sdk\platform-tools" to System Properties-> Advanced-> Environment Variables-> System Variables-> Path
One of the reasons of problems in device connection is a long USB cable or a two-piece cables like keyboard USB. try to connect your device to PC directly by a short cable.
I guess that you might suffer from the issue that the manually started emulator got disconnected somehow, shown with a message like
Error: emulator-5554 disconnected
in the Eclipse console view. There are several related questions and answers on stackoverflow like Why do I get a emulator-5554 disconnected message,
but for me none of those answers helped.
Whenever I see the error message for disconnection occur, I just shutdown that emulator and start it again. Normally that already "fixes" the problem, it just works on the next attempt (for me).
I was just experiencing this issue also. I agree with breceivemail, the ADB reconnected to the emulated device after reset, but there is a shortcut using Eclipse:
In the DDMS view => Devices window => View Menu (the down triangle in the header) => reset adb
You can choose the target device manually by changing the run configurations.
Run -> Run configurations -> choose your App -> Target tab -> select "Always promt to pick device"
If your device isn't available you will at least don't start a new Emulator.
If the emulator is still active, you can use adb to connect to it via tcp. In this way you can connect a disconnected emulator to your development system's loopback one port higher, just like if you are using emulator-5554, you can connect to it by using a higher port.
adb connect localhost:5555
There was been an issue with this technique, where the emulator control becomes inactive, and the developer cannot send GPS coordinates or SMSs or calls to emulator.
There is a one click method to do this
Open notepad
Type the below code
#echo off
adb connect localhost:5555
Save the file as your_file_name.BAT
Copy the file to Android SDK/platform_tools
Create a shortcut, give it a custom icon, use it anywhere you like
Open the DDMS view from Eclipse, and simply click on the emulator name you want connect to in 'Emulator' tab.

Android adb "Unable to open sync connection!"

I can run and debug my Android app on my phone just fine, most of the time. Then, seemingly randomly, when I try to run or debug my app from Eclipse, the Console in Eclipse says:
[2010-10-12 09:36:48 - myapp] Android Launch!
[2010-10-12 09:36:48 - myapp] adb is running normally.
[2010-10-12 09:36:48 - myapp] Performing com.mycompany.myapp.MyActivity activity launch
[2010-10-12 09:36:48 - myapp] Automatic Target Mode: using device 'HT01TP800561'
[2010-10-12 09:36:48 - myapp] Uploading myapp.apk onto device 'HT01TP800561'
[2010-10-12 09:36:48 - myapp] Failed to upload myapp.apk on device 'HT01TP800561'
[2010-10-12 09:36:48 - myapp] java.io.IOException: Unable to open sync connection!
[2010-10-12 09:36:48 - myapp] Launch canceled!
Retry: doesn't help, same messages.
Restart Eclipse: doesn't help.
Restart adb (adb kill-server && adb start-server): no errors, doesn't help.
Reconnect the phone: sometimes helps.
Reboot the computer: kind of drastic, haven't tried this yet.
Using Ubuntu 10.4, Eclipse Galileo 3.5.2, Android SDK 7, ADT plugin 0.9.6, Nexus One, Android 2.2.1.
Any bright ideas?
I was having exactly the same problem, but I already had my phone connected to the computer's USB port. Sometimes disconnecting and reconnecting the cord worked but then it stopped working completely.
However, disabling USB debugging on the phone and then re-enabling it has worked so far. Hopefully it keeps working! These fixes really seem like silly hacks.. I'm not sure what the underlying problem is.
I was able to clear this only by cycling the USB Debugging option on the phone.
This may also be related to a "too many open files" issue. I manually tried to install the app when getting the "sync" error above and that's when I got the "too many open files" clue. one brute workaround, based on some old posts, seems to be to restart the phone, and one google engineer suggested doing it twice, the second time before it goes into sleep mode the first time (details on why in the post).
That was a few years ago, and maybe they've fixed it, or just did some things to get around it in the usual cases and the reinstall-as-part-of-development is not a case that it addresses.
Nexus One here, CyanogenMod 7 (Android 2.3.7)... disable and reenable:
Settings > Applications > Development > USB debugging
And everything works now on Eclipse and Mac OS X 10.7.3.
I have been having the same problem when I have the phone connected through my keyboard's USB hub. IT went away when I connected straight to the computer's USB port.
I have had the same problem and restarting ADB wouldn't work for me. Sometimes rebooting my phone worked but not always, I was unable to program for about a week because of this glitch and I think I finally found a workaround! :-D
First of all, kill every program running on your phone. Having some kind of taskmanager makes this a quick task, otherwise you'll have to manually kill them all one at a time.
If that doesn't fix it, you will need to go to your phone settings, then go to "Applications", then go to "Running services", and kill every service in there. I'm using a Droid Incredible and I have yet to have this not work for me. :-)
So, the short answer is, kill all apps, and all services.
Also, keep in mind, you will need to close, and re-open eclipse to see if this fix has worked for you. I hope this works for you, I know it did for me! :-D
When this happens on the Kindle Fire I just power it off and back on again.
I fixed it just by disabling and enabling the debugging configuration on my device (SonyEricsson Xperia)
This error occurs when somehow the Android Debug Bridge , which is the tool to send data from our computer to the connected device, disconnects. As we know, there are some layers to get connected like the adb itself and of course, the last layer is the USB cable, so when you already tried to restart your adb script and seem not working, you just need to reconnect your cable.
I see this problem regularly in both attached devices (Phone or Tablet) and even the emulators. I noticed that the problem often follows periods of inactivity (after a lunch break for example). It may be that the Operating System on the development machine is trying to conserve resources and adb just isn't all that JIT friendly.
On windows I have to close the IDE and open Task Manager and force stop (kill) adb, then relaunch Eclipse. This always works for me...
I noticed if I set a higher priority in task manager for adb, this problem is greatly reduced--although it can still happen.
Restarting the phone has also fixed this problem for me whenever reseting the usb cable didnt fix it
The solution is likely to run on your android phone (on local terminal or ssh terminal):
$ stop adbd; start adb
I don't like overkill solutions like rebooting hte phone... and this is usually not needed under Linux. I experienced the same problem when connecting over Wifi, so USB is maybe not responsible at all. Reading the answer from user655489, I got the idea to run lsof, and then lsof | grep adbd | wc -l => I think I had over many sockets open with all FD from 0 to 1023 in use... how suspicious.
I ran killall adbd, then restarted adbd per How can I connect to Android with ADB over TCP? And the problem was gone.
The cause is that, at least when debugging and having to kill my non-working apps, that several of the sockets never get closed.
What helps for me is the following:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
If you are debugging on AndroidX86 (or otherwise have root access to your Android developer machine)
Kill the "adbd" process.. and let it restart.
e.g.
[On Android VM]
kill adbd (e.g. kill `ps a| grep adbd | awk ' { print $2 } ' `)
/sbin/adbd will restart automatically
[On DEV station]
[dev station] ./adb disconnect
[dev station] ./adb connect
If you don't have root, probably toggling USB debugging, rebooting, etc could also help.
As it also restarts adbd
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I have been experiencing this problem very often (I mean like every second time I launched Debug). I was using a rather long USB cable. I switched to the original HTC USB cable which is short and the problem was gone!
I experienced this problem when my USB cable was connected to PC via keyboard USB :O. When I connected it to PC directly my problem solved.
I hope this works.
Enjoy!
As per Maven Explanation I tried this solution. but I was getting the same problem. So I restarted the device. And it started working perfectly.
Try this,
Disabling USB debugging on the phone and then re-enabling under
Settings -> Applications -> Development -> USB debugging
its works fine.
This solution worked for me
Click Revoke USB debugging authorizations.
Click OK.
Reattach USB.
Click OK for Permissions.

Categories

Resources