APK does not install and device is unauthorized and offline - android-studio

I have a device running Android 6.0.1 and I'm working with Android Studio 2.3.3 on a Mac. When I try to install/run my application (hello world) I get this message.
com.android.ddmlib.AdbCommandRejectedException: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
Error while Installing APK
I know questions like this have been asked all over this site and I have looked though most of them and followed these suggestions
Turn everything off and on a few times
Ensure USB debugging in enabled in developer settings
Stop and start the adb server
Try a different deployment target, virtual devices work fine
My current theory is that my device is not authorized either because my device is not a phone/tablet/watch, it is just a SOM and carrier board.
My only other thought is that this is caused by the device being offline.
When I am selecting a deployment target I can see my device but it says [OFFLINE] beside it and it is slightly greyed out. I don't fully understand what this means given my device is connected the same network as my Mac they can ping each other.
So my question comes down to this
What other troubleshooting can I try?
Is it relevant that my device is offline/ what does that mean/ how can I go online?

The issue was with the .img file I used when getting the OS running on my device. I reinstalled the OS and everything worked after that.

Related

BlueScreen after Run emulator android studio

When im run android studio, or run emulator for android studio with manually or with cmd, always get bluescreen.
it say "your pc ran into problem and needs to restart. we're just collecting some error info, and then we'll restart for you"
Stop code: IRQL Not Less or Equal
how can i fix it ?
im trying download another emulator and following tutorial on youtube, but it didn't work
It depends on various factor,
I happened to get this issue because of my old PC with Lesser RAM size(4GB) and to rectify it, I connected my Android phone to PC for debugging/running apps from Android Studio.
You need to enable USB Debugging in your phone for that purpose.
NOTE:
You can view this blog post I made, which addresses the same issue.
https://whysurfswim.com/2015/07/11/sick-of-your-avd-theres-a-alternate-for-it/
I had almost same problem. When I tried to install my app in emulator(Ram 8gb), my emulator crashes but kept running in background. As a result, I was unable to shut down my pc and have to disconnect power for shutting down.
use your phone for debugging your app. you can connect your phone using wifi. link here
Sometimes it happens beacause of outdated drivers, try updating your drivers to latest version, and update the windows 10 to latest version. Also try by deleteing your current emulator device and create new device by enabling software renderer. For lower end pcs like yours I would recommend to use real device instead of emulators ans use ssds for better performances.

Android Studio: Unable to open connection to: localhost/127.0.0.7:5037, due to: java.net.ConnectException: Connection refused

I'm taking the first steps in android development. Started working through this guide https://developer.android.com/training/basics/firstapp/running-app and the error occurred when the program is run on the device.
First of all, my device is not in the list of connected in Android Studio:
adb devices doesnt see my device when Android Studio is running, but if I close Android Studio, adb devices shows my device
When Android Studio starts, it shows an error and logs all the time this error flashes:
I tryed this this solution but it didnt solve my problem:
I dont know, why Android Studio try to connect to weird address localhost/127.0.0.7:5037?
I forgot. I edited /etc/hosts and commented line
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
After uncommented the line and restarted the Android Studio, I've solved my problem.
in my case in /etc/hosts I had the following line that i removed
0.0.0.0 localhost
I've catched this error under:
Android Studio 3.1.4
Android Debug Bridge version 1.0.32, Revision eac51f2bb6a8-android
Also i'm working in the office with some active firewall, antiviruses, monitoring etc.
My local host in the "/etc/hosts" was commented.
I solved this issue, but it was only an adb connection problem.
First, you have to enable all features in a device's developer menu
(debug with USB, upload via USB, usb connection type - charge only),
security menu (allow unknown sources);
Second, you have to set an allowance on the device to accept commands
from a current PC. Some devices do not show a dialog. To force this,
open a terminal console in the Android Studio, type in a command
"adb logcat" (this push adb to connect with current device), you
should see a dialog on the device's screen. Choose "Allow". To exit
from logcat command, press ctrl+x/ctrl+c or ctrl+break;
After this, you should see the device in the Studio's logcat drop box as [disconnected];
Open the consloe again and type "adb wait-for-device", this should set a stable connection with device.
It helped me.
I had a similar issue with Android Studio 3.3.1 (MacOS) when I run my app, it could not detect any devices in the Select Deployment Target dialog window after initializing adb. It produced the following error:
Unable to open connection to: localhost/10.0.2.2:5037, due to: java.net.ConnectException: Connection refused
I checked in /etc/hosts, and found the following line:
10.0.2.2 localhost
Commenting out that line solved the issue.
In windows 10 I to need add path of ADB directory to environment PATH. And It helps.
The problem can be due to the fact that it is missing the adb driver for the specific phone, as you can verify from the device manager.
You have to donwload and install it from the manufacturer, if it is available.
In my case, this seems to be still an open issue, but I've finally found the correct driver and installed it, as suggested in the developer documentation, by following the appropriate links (in my case I landed in a xiaomi Chinese page, containing the link to the rar archive of the working driver).
Having done that first, I could finally see an unauthorized device from adb devices (before that, no device was found instead, since it was unrecognized at the operating system level in the device manager) and, eventually, the suggestion from Sergio, typing adb logcat in the terminal, finally prompted the authorization from the device.
Issue solved!
Check if the port is binded to any other connection in your computer. This may be the error which is caused de to ports inavailability.
This Error ConnectException is caused due to SocketException so i will start digging with the port's status.

Android Studio - Device is connected but 'offline'

This is quite a common question, but none of the solutions appear to work for me. First time asker, so apologies if I get the conventions wrong.
I am trying to connect my Galaxy S5 to my computer running Ubuntu 14.04 so I can do some android development. I have recently downloaded and installed Android Studio and the SDK and my device is detected when it's connected via USB but the device either appears as 'unauthorized' or 'offline'. I know I should be expecting the RSA key prompt but this never appears.
I have tried:
Checking debugging was enabled
Running adb kill-server and adb devices
Restarting (the device, developer options, the machine)
Simple unplugging and replugging the USB cable
Checking my adb version (it is 1.0.31)
Trying different USB ports
Revoking USB debugging authorizations
Toggling enabling ADB Integration from within Android Studio
Connecting as PTP device and MTP device
I have tried it on a separate machine that runs fedora and this works fine with no issues, the promopt appears right away. Therefore I imagine it is not the USB cable that is faulty.
Any ideas?
Try these:
Unplug and replug the USB cable.
If it still doesn't work, unplug the USB cable, disable then enable USB debugging in the device settings.
If the above two methods fail, reboot the device.
If rebooting the device also fails, reboot Android Studio too.
If reboot Android Studio still fail, try adb kill-server then adb start-server.
Try killing adb adb kill-serverthen disable usb debugging and then start adb by adb start-server then enable usb debugging and plug phone again and huh don't let phone sleep between process
EDIT
There turned out to be a problem with my laptop's ADB RSA key. I'm assuming my G3 was rejecting a bad key and disallowing my laptop to connect to it via ADB.
ADB saves a key file in one of multiple places on a Windows computer, the first is in the location where adb.exe is (C:\android), the second is in the user's >profile (C:\Users*username*.android), the third place is in the Windows system files (C:\Windows\System32\config\systemprofile.android), the file is >simply named "adbkey" with no extension. If there is no key file when ADB runs, it will generate one automatically.
Mine was located in my user folder (C:\Users*username*.android). All I had to do was delete the adbkey file (there was also a file named "adbkey.pub" which >I deleted as well), restart the adb server in command prompt (adb start-server) and plug my phone in. I instantly received the RSA Fingerprint Key window on my >G3 allowing connection between the two devices. Then typing "adb devices" returned my phone's serial number followed by "device" showing it was available. >I went back to the C:\Users*username*.android\ folder and sure enought there were new "adbkey" and "adbkey.pub" files.
got from XDA
EDIT 2
TRY this steps too
Navigate to where .android is stored
open .android and delete file named as adbkey and adbkey.pub
Start ADB then typeadb kill-serverand adb start-server
My fix to this issue:
Android settings
Developer options
Revoke USB debugging authorizations
Replug in device and accept authorization as usual.
Profit
Step 1: Turn off USB DEBUGGING in Developer Options
Step 2: Remove USB Cable
Step 3: Turn on USB Debugging(This rests USB Configurations)
Step 4: on Command Prompt enter adb kill-server and then adb start-server
Step 5: Connect the USB Cable
Step 6: Check Devices connected in Run in Android Studio(you should be able to see your device listed)
Step 7: If you want to continue running using the cable this would be good enough
(If you want to do Wireless Debugging continue with below step)
Step 8: type adb tcpip 5555. If no error is displayed remove USB Cable
Step 9: Look up IP Address of your phone from About abd then type adb connect xxx.vvv.b.n(your phone's IP)
Step 10: Check in Devices in Android Studio again and you shud see you r device in List of devices. If yes,
If you are on windows and you encountered the same problem, try killing the adb.exe process from task manager and then rerun your app.
Change the USB cable !!!!
I can't explain this technically, however after a lot of trial and error, this what have worked for me.
Could not get Samsung Note II (N7100) to connect.
Step 1. Follow answer from user4847410 above. Next time you connect your phone it will come up with an authorisation message and you're in.
Step 2. I also swapped my cable.
Step 3. Check USB port as if you install on one particular port then another port may not be ok for you.
Note: made two batch files
adb-fix.bat
adb kill server
adb start server
pause
adb-devices.bat
adb devices
pause
-- voted for that correct answer but I don't have enough kudos so it was removed! --
To fix this, use USB2 instead of USB3
A shorter cable did the trick.
It turns out that the wire thickness used inside the cable impacts on the resistance of the cable assembly – this resistance causes energy loss inside the cable when an attached load draws a current, and causes a voltage drop which can reduce the voltage to the end device to a point where it is not possible to charge quickly or completely.
http://goughlui.com/2014/10/01/usb-cable-resistance-why-your-phonetablet-might-be-charging-slow/
Change your USB Preferences to File Transfer if you use your smartphone to debug.
There are several option :
File Transfer /* Choose this one */
USB Tethering
MIDI
PTP
No Data Transfer
I had a long white cable. Just wouldnt stay connected. Switched to another, shorter, black cable and it works 100% of the time.
Disabling and Enabling the Developer options and debug mode on the Android phone settings fixed the issue.
Earlier for almost 3hrs I did:
I tried everything given in several sites and my android device never came online.
when I was running adb kill-server and then adb-startserver the "Device File Explorer" on the right bottom of the android studio showed "Device is not online (DISCONNECTED)".
Here is how solve this:
Revoked all USB debugging authorization on the device under "Develop options"
And I added sudo to command "sudo adb kill-server" and then " sudo adb start-server".
After this the message in "Device File Explorer" in android studio changed to "device is pending authentication please accept debugging session on the device". But no message appeared on the device. Tried stopping-restarting adb, connect reconnet usb cable, stop-start usb debugging but nothing worked.
Went back to device and changed the device usb settings from usb charging to "PTP", and, restarted the Android studio. And, boom, the message appeared on the phone to accept the debugging session on device.
use this command
-> adb disconnect
-> adb connect <ip address for your mobile:port number>
Eg : adb connect 192.168.2.58:5555
You can try this:
Go to tools/enable adb integration and uncheck it.
now check it and run again. Next time, android studio will restart adb and it may find your device.
Restart adb by issuing these commands in cmd
adb kill-server to kill existing adb session followed by adb start-server to start a new adb session
Disable and re-enable USB debugging on the phone and accept RSA fingerprints if asked by phone
Rebooting the phone if it still doesn't work.
If all above don't solve your problem, you may try delete environment variable named "ANDROID_SDK_HOME".
It really solved my problem. Hope it Help you!
This fixed for me
uncheck launch in tool windo
Source
https://github.com/google/android-emulator-m1-preview/issues/76#issuecomment-1023563846
This problem is because you have used an old adb version and not support on your device. or you have more than one adb
The key is:
make sure you have a latest adb executable on your SDK
Make sure to run adb command from "SDK_DIR/platform-tools/" because this should be the latest version (type command "which adb" to check) if u have more than one adb file, you can rename another one.
in my case, on my Windows 7 i have one more adb on "C:\Windows\adb.exe" and its an old version, so my adb command always run from that file. I fixed the problem by running adb form my sdk directory "SDK_DIR/platform-tools/adb.exe"
On windows--> Launch your terminal from the platform-tools folder inside android sdk.
Then use the following commands
adb kill server
adb start server
it should work
Try upgrade your Android SDK Platform as below steps:
Run the SDK Manager
Execute "Install packages…"
Restart the SDK Manager
I tried and it's ok for me.
ref: link
You maybe having an older version of the ADB, Update the tools package and that should bring down the latest ADB.
I also recently had this problem and I solved it by rebooting Android Studio. But my friend had to have the original cable for his device, no other cables worked.
In my case (same problem - that Nexus 5 is connected but with "offline" status) the problem was solved by "Invalidate caches and Restart" in Android Studio.
Suppose that problem was in adb and restarting Android Studio causes to adb restart.
Download and Install your device driver manually through visiting manufacturer website like :Samsung,micromax,intex etc.
In my case the problem was that I used a USB extension cable. As soon as I plug the microUSB cable right into the PC the device has detected.
In my case, turned out that you need to be logged as owner of device to properly accept the USB debugging.
Tried the "Disable and re-enable USB debugging on the phone" step but didn't get the RSA prompt on "normal" user, switched to owner and tried again and got it.
I had this issue on a device with USB-C using a microUSB cable with a USB-C adapter. After switching to a USB-C cable without any adapter it worked. I only saw this issue on a LeEco.
I tried most of the things on this page and none of them worked for my Samsung S5. However, when I switched the cable to a USB-C type the problem seemed to be solved...until next time.
Besides the solution mentioned above, try to download Samsung's Android USB Driver for your platform. Here is a link to the Windows one:
https://developer.samsung.com/galaxy/others/android-usb-driver-for-windows
If your app doesn't manipulate WiFi connections - another slightly different solution, which bypasses USB issues entirely - enabling a wireless debugging connection - ADB over WiFi/TCP/IP.

Flash Keon with firefox OS 1.2

I am having problems trying to flash my device with 1.2 in order for me to start using the device for dev.
I have Android SDK installed.
When I run the following command in Terminal -
./flash_mac.sh
I get this message back -
adb server is out of date. killing...
* daemon started successfully *
error: device not found
If I run this command -
adb devices
I get the following back -
List of devices attached
full_keon device
Can anyone help me sort this?
Thnaks
Rory
I have managed to flash the device, I simply re-connected the USB cable while Daemon was being started again.
Obviously anyone else finding this issue, I imagine they will need to update ADB Server.
Not sure how to. As I literally just installed it via Android SDK.
Thanks
Rory

Windows phone 8.0 error 0x89371B01 when trying to deploy app

I cant find information on this error anywhere. I am connecting to a brand new lumia icon (AKA lumia 929). Dev account is registered. I have attempted:
reinstalling windows phone SDK
restarting phone
restarting computer
ensured the app runs on the emulators properly. the only required capability of this app is network. Capabilities have not been changed from the defaults since the project was created. none of the manifest xml files have been touched.
ensured phone software version is up to date
ensured apphub account is valid and active
ensured the windows phone developer registration tool worked, unregistered and re-registered the phone to make sure
restarting the "ip over usb" windows service thingy
changing the platform built target to ARM or AnyCpu (no difference, same error)
tried alternate deployment methods such as windows phone power tools (the xap deploy) and I get the same error when trying to connect (so I know it's not an issue with visual studio, nor is it an issue with the app code)
I can successfully deploy separate code to a separate WP7 device (so I know it's not an issue with the computer)
tried multiple usb ports
tried two separate laptops
tried visual studio 2013 and 2012
The behavior is this:
Connect the phone via usb and unlock it
Attempt to connect to phone via windows phone power tools OR deploy an app via visual studio
System hangs for about 90 seconds and seems to time out
Error appears
I am able to view the phone contents, name it and explore it on my laptop, but when it comes time to deploy something I am stuck.
Error message is simply: 0x89371B01
What does that mean? Has anyone else run into this?
Have you checked the device drivers on your Windows 8.1 machine? It could be a driver issue with your USB drivers on the computer.
I have also found that, once you get it connected, going into the Device Manager and deleting the device from there and forcing it to reload has helped me in the past.
Out of curiosity, try running "sfc /scannow" at a command prompt on the PC. It may require admin elevation. I've seen some bizarre behaviors due to dll problems in sxs in win 8.1, wondering if this could be caused by that kind of thing.
Couple of things to try:
Have you installed the GDR3 Emulators and tried running it on the 1080p emulator? It looks like the 929 is a 1920x1080 phone and will have the latest the latest updates installed. First place to check.
Based on this feedback in another stackoverflow question it looks like someone was having a similar issue and disabling Hyper-V resolved it for him. If you disable Hyper-V and it works, try re-enabling it and see if you still have the issue.
jmshapland had the correct answer for me, with the same issue. Disabling Hyper-V did the trick! No thanks to microsoft phone dev center forum posting on the issue..
http://social.msdn.microsoft.com/Forums/wpapps/en-US/24bd3e48-e7b4-4d00-8d69-193f49989ce0/0x89731b01-error-during-deploy-to-device?forum=wpdevelop
Looks like I'll be disabling Hyper-V to test on my device, and re-enabling to work in emulator mode:
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
and
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
OK I was able to come up with a repeatable solution for the issue. Im HOPING that by posting this I dont tempt fate and have the phone not work again!
Here are the steps I did to resolve it (not sure if all of them are necessary):
On phone, disable wireless
Connect phone to laptop
Open device manager and click to show ALL HIDDEN DEVICES (including hidden devices is important)
Uninstall ALL phone-related devices (one in portable devices, several in USB
devices) anything that mentions lumia must go
Disconnect/reboot phone
Reboot laptop (there seems to be a process keeping the port open)
I had connectivity, then I lost it, then I re-gained it using these steps and it seems to be reliable for me (so far)

Resources