Why is "adb install (my APK)" triggering "can't find service: package"? - android

I am starting up an android virtual device, but I am getting:
Starting emulator for AVD 'avd.1'
pulseaudio: pa_context_connect() failed
pulseaudio: Reason: Connection refused
pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver
emulator: Listening for console connections on port: 5558
emulator: Serial number of this emulator (for ADB): emulator-5558
The emulator is coming up but I see no icons on it so I'm wondering if the errors listed above are "showstoppers"? Then when I try adb install bin/my.apk I get the error Can't find service: package. So it seems adb is not communicating with the AVD correctly. However, adb devices does show emulator-5558 listed above. Any advice would be really helpful.

You have essentially answered your own question while asking it. The root of the problem is that the emulator is not setup properly (evidenced by the system UI not loading). When Android can't boot properly, it is likely to fail to start some system services (in this case, the package service).
The solution is to recreate the emulator, possibly with a different system image (in case the one you have been using is corrupt). If you are using an official image, try switching API levels, or switch from a GMS-enabled emulator image to a non-GMS image (or vice-versa).

It also happened to me after closing the emulator while debugging. Yes, not the best idea...
The solution for me was:
Click on Tools > AVD-Manager.
Click on the arrow to bottom on the right of the new window from your (virtual) device.
Click on "Cold Boot Now".

Don't forget to enable usb debug mode and in developer option to consent data file transfer, for me it solved this issue, hope this help

You can also get this fault when delpoying to physical devices.
The solution is to restart the adb server, using:
adb kill-server

Related

Android Emulator keep showing allow USB debugging prompt

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.

Android Device Monitor did not display the process I want ,but display others,why?

img
here is the image. I can't find my app's process, but others I can see. why did this happen? what should do? Thanks.
Some possible solutions:
On your notification bar, expand it and click the connection. Then select connect as Camera (PTP) (not as media device)
Try with another USB cable.
Go to your SDK manager and install Google USB Driver (I see you updated your answer regarding this)
Follow the instructions on OEM USD Drivers
if you get errors like below:
Unable to get view server version from device;
Unable to get view server protocol version from device
Unable to get the focused window from device
Unable to debug device
try to check these points below:
if signed app running on the phone, DDMS can't get the process info;
otherwise, can.
if use Virtual Device, then the DDMS&HierarchyView is useful;
reinstall app from IDE (if app process running stop it from IDE or force stop if through android setting)
if nothing happened try restart ADB
$ adb kill-server
$ adb start-server

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:)

'adb devices' showing dummy device

I have been facing this problem for quite sometime now. Running 'adb devices' shows me an additional dummy device although its named as emulator-5554. FYI, I don't have any emulator running as well.
adb devices
List of devices attached:
xxxxxxx device (Actual device)
emulator-5554 device (Dummy thingy shown as device).
How do I clean up this mess?
Same problem for me but I don't see any Bluestacks service in my services list. after
adb devices shows emulators I didn't have, I usually just type the command
adb kill-server
and running the
adb devices
once more shows only the devices that are connected.
I had the same issue. I did this and now everything is ok
click Windows+R
type services.msc
stop BlueStacks Android Service
I have figured out the issue. I had installed Bluestacks for Mac for trying out Android apps on Mac. This was running an emulator with a different name.
Figured it out by taking a screenshot of the emulator and it showed the launch screen of Bluestacks. Uninstalled Bluestacks and all is well now.
the adb server is scanning for emulators on all even local ports from 5555 to 5555+128 (5683). If you have a custom service which use one of these ports... You are stuck with the "adb -d command" requirement
pls check in task manager whether emulator-arm.exe is running. If so, try stopping both adb.exe and emulator-arm.exe
I had the same problem and non of these answers helped. So I figured out that my system didn't shut down properly and that's the reason I have a dummy emulator-5554. The solution was to create a new emulator with a name then launch it? While it's launching kill the server using cmd until when the emulator powers on and you can see its name under Devices in DDMS. After this shut the emulator...emulator-5554 is gone, Now you can start Bluestacks and connect
I was facing the same issue, and that due to BlueStacks too. In case you have Windows and you don't want to remove it, then you can stop its service "BlueStacks Android Service."
To do that click Windows+R, type services.msc then stop "BlueStacks Android Service"
Reference:
http://forum.xda-developers.com/showthread.php?t=2612389
Eclipse emulator NOT BlueStacks:
In the case of the eclipse emulator running in the background and you don't know how to close it, just go to devices tab and choose the dropdown menu on the right, then Reset adb. OR, just reset the adb using adb console.
Just open task manager and end task bluestacks
I also meet the same problem.Here is my answer to solve this problem.
in Windows system.
1.in cmd terminal,usr cmd netstat -aon|findstr "5555"
2.use cmd tasklist|find "PID",the PID para should be a process number which is the result of the first step .
3.changed the Port No. to other ,which should not be "5555"
That's done.
After trying:
adb kill-server
stopping adb.exe in task manager
adb usb
and a few other stuff I can't even remember. . .
I restarted my computer and the dummy-device was gone!

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.

Categories

Resources