Android Emulator Tips and Tricks [closed]

你离开我真会死。 提交于 2019-12-03 01:34:06

问题


What is your Emulator feature that you could not work without?

Which unknown great shortcut, console command or startup option is there that you discovered and you think has to be also known by all other Android devs?

Share your Emulator wisdom with us.


回答1:


F6 - start track ball emulation

When working with high resolution screen, one can reduce the size of the emulator to make it fit better on PC screen: AVD Manager - Start - check "Scale display to real size" and set Screen size to a suitable value (6 works for me)




回答2:


Not exactly an emulator feature but related.

When using Eclipse for Android development, the debug certificate that is automatically created only lasts 1 year. When it expires, it's a pain to have to delete all your development .apk files, because the new certificate doesn't match so you can't upgrade them in all your AVDs. You have to get another development MAP-API key as well. The published recommendation is to simply delete the debug.keystore file and Eclipse (ADT really) will create a new one for you, again with a 1 year expiration. But you can create your own debug certificate in debug.keystore with whatever expiration you want. Do this in the .android folder under your HOME directory:

keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 14000

ADT sets the first and last name on the certificate as "Android Debug", the organizational unit as "Android" and the two-letter country code as "US". You can leave the organization, city, and state values as "Unknown".




回答3:


You can enable/disable the Emulator Network with: F8

Great for testing service interruptions while your app is connected to some web based service. It allows very fast disabling just at the moment a download or a webservice started.




回答4:


You can rotate it: Ctrl + F11.




回答5:


You can try your hands on a bunch of tricks using keyboard key and taken from the Android official documentation. See the below image.




回答6:


You can get the Android Market running in the emulator.




回答7:


Demonstrate an android app from a USB stick

Assuming you want to show a friend/client your app and their machine has no Android SDK, Eclipse or even an uptodate JRE, you can put all you need on a USB drive without affecting your development environment.

Make an 'androiddem' folder on the stick, copy a minimal sdk (don't need the docs or samples) with the platforms you need and a Java runtime to their own folders.

Open a DOS box from the root of the USB drive and set a local environment variable ANDROID_SDK_HOME to the root of the drive. (This env variable is a bit of misnomer if you use Eclipse as it doesn't need it and picks up the SDL location from the general Android preferences). It does control where the AVDs get created though, so once you've set it to h:\ (say), you can drop down to to the tools directory on the stick and create AVDs in the normal way - they will end up in .android on the stick.

If you copy the .apks that you want (make sure they were signed with a release key) to the stick, then from another DOS box(with the ANDROID_SDK_HOME set as before you can use the adb commands to install the apks to the AVDs you made.

All you have to do then is take the stick to the target machine, open a DOS box again, set the ANDROID_SDK_HOME, prepend the JRE to the path and run the emulator nominating the target AVD.

You can simplify the process by creating batch files on the stick to set env variables and paths.




回答8:


Keep the emulator open while developing to avoid the boot time.

(Source: Pragmatic Programmer's Hello Android book - Ha, I just read this yesterday.)




回答9:


You can use DDMS to create screenshots from applications running on hardware. Just hit Ctrl-S from within the DDMS program. Great for creating screenshots for the Android Market, especially if your application runs poorly on the emulator.

I'd been capturing screenshots from the emulator and trimming them with Image Magick until I had this pointed out to me by a colleague at work.




回答10:


Using DDMS to debug a service which has no Activity.

Assuming you've written a service in its own apk which to be used by another application, then it's not possible to set break points in the service app's code and have them trigger when the other app runs and invokes the service.

If, however, you go to the DDMS perspective, find the service's thread and highlight it, then click the bug icon in the DDMS, breakpoints are triggered.

This answers one of my own (unanswered) questions.




回答11:


Use ADB commands to optimize your work. Very useful examples:

adb shell am broadcast -a com.test.IntentName - simulate an intent

adb shell date -s 19860407.115033 - change date/time (to my birthday ;)

adb shell dumpsys alarm - print registered alarms




回答12:


1) Reset adb every time the console has adb errors.

2) Use Launch options wisely:

2.1) If you have problem emulator "not responding" every time it starts, restart emulator with "wipe out user data". It will clear all apps installed before and make emulator fresh.

2.2) Checking "Launch from snapshot" will save time when starting emulator. It reads from a snapshot (if there is any).

2.3) Checking "Save to snapshot" will save a snapshot to run emulator immediately next time. Uncheck it if you want to close the emulator faster.

3) Backup "sdcard.img" if you intend to change its size. I used to lose data when I try to change its size.

4) Download and install offline Android SDK if you have Internet connection problem on you computer.

5) Install Android Market on emulator.



来源:https://stackoverflow.com/questions/4053752/android-emulator-tips-and-tricks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!