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

Exception or error:

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.

How to solve:

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

Leave a Reply

Your email address will not be published. Required fields are marked *