Android: Problems debugging with the emulator from

2019-07-06 04:02发布

问题:

This is driving me crazy. Like these people, slow-android-emulator, I'm finding running the emulator from eclipse is slow and problematic. As suggested, I've tried running the emulator seperately. But then I don't get my latest changes. I don't know eclipse that well, but I would like something like 'build' and then somehow load the latest image into the emulator.

Also, I've tried keeping the emulator open and the continually use run->debug, but after 2 or 3 times, I get errors like the following:

Failed to install HelloAndroid.apk on device 'emulator-5554': timeout
Launch canceled!


emulator: ERROR: the user data image is used by another emulator. aborting


Waiting for HOME ('android.process.acore') to be launched...
emulator-5554 disconnected! Cancelling 'com.example.helloandroid.HelloAndroid activity launch'!

java.lang.NullPointerException
at com.android.ddmlib.Client.sendAndConsume(Client.java:571)
at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.java:670)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)

I've tried killing and restarting the adb server to no avail.

Once again, briefly, I would just like a 'system' where I can effectively make changes, load them into the emulator and test.

回答1:

The emulator is usually slow, but once started usually I never had to restart.

If you feel that running emulator from outside eclipse is faster, then you can run the emulator outside eclipse and in the android application Run --> Configuration, you can choose "preferred avd" and uncheck automatic target mode. (Also it tells me that your eclipse probably does not have enough memory. You need to change vmargs if you have allocated very little memory. More on that later).

Also when you want to debug again after making some code change, are you closing the debugging session (The red button in your debug window) and starting a new one. The emulator does not handle hot swapping all that well.

(Note: Please try using Jconsole or some other profiler and paste the memory usage or at least check memory usage in task manager.)



回答2:

please try current avd(emulator) cancel and again start that avd(emulator).