3. ANDROID SDK
Install x86 version:
http://developer.android.com/sdk/index.html
Includes:
• Eclipse + ADT plugin
• Android SDK Tools
• Android Platform-tools
• The latest Android platform
• The latest Android system image for the emulator
4. INSTALL WINDOWS DRIVERS
For Samsung go to http://developer.samsung.com:
http://developer.samsung.com/android/tools-sdks/Samsung-Andorid-USB-Driver-for-Windows
For Kindle check it here:
https://developer.amazon.com/appsandservices/resources/development-tools/ide-tools/tech-
docs/01-setting-up-your-development-environment
SDK Manager Tools Manage Add-on Sites User Defined
Sites New insert url http://kindle-
sdk.s3.amazonaws.com/addon.xml OK Close
Now in SDK Manager packages go to Extras folder Check Kindle
Fire USB Driver press Install
Go to sdkextrasamazonkindle_fire_usb_driver on your PC
Run KindleDrivers.exe
For steps with pictures go to https://developer.amazon.com/post/Tx3RZFBU0KJTSWS/Setting-up-the-ADB-driver-for-Kindle-Fire-Devices.html
5. SDK MANAGER
SDK Manager is used for separate downloading tools, platforms, and other components into packages.
Launch SDK Manager:
• From Eclipse (with ADT), select Window > Android SDK Manager.
• On Windows, double-click the SDK Manager.exe file at the root of the Android SDK directory.
• On Mac or Linux, open a terminal and navigate to the tools/ directory in the Android SDK, then
execute android sdk.
SDK Tools Required.
SDK Platform-tools Required.
SDK Platform Required (at least one platform)
<sdk>/platform-tools/
./adb (console tool)
<sdk>/tools/
./android (Android SDK Manager)
./android avd (AVD Manager)
./monitor (Android Device Monitor)
6. ADB DEBUGGING
Adb - middleman between a device and your development system. It provides various device management capabilities, including
moving and syncing files to the emulator, running a UNIX shell on the device or emulator, and providing a general means to
communicate with connected emulators and devices.
Dalvik Debug Monitor Server - DDMS is a graphical program that communicates with your devices through adb. DDMS can
capture screenshots, gather thread and stack information, spoof incoming calls and SMS messages, and other...
Device or Android Virtual Device - An adb device daemon runs on the device or emulator and provides a means for the adb host
daemon to communicate with the device or emulator.
7. ANDROID DEBUG BRIDGE
Android Debug Bridge (adb) is a command line tool that lets you
communicate with an emulator instance or connected Android-
powered device. It is a client-server program.
You can just send commands through Terminal to it:
./adb devices
./adb install <your_apk>
And DO NOT FORGET to enable usb debugging in the developer
settings (go to settings developer options enable USB debugging)
8. DDMS
Dalvik Debug Monitor Server:
• LogCat - Lets you view system log messages in real time.
• Incoming call and SMS spoofing
• Devices - Shows the list of devices and AVDs that are connected to ADB.
• Emulator Control - Lets you carry out device functions.
• Threads - Shows currently running threads within a VM.
• Heap - Shows heap usage for a VM.
• Allocation Tracker - Shows the memory allocation of objects.
• File Explorer - Lets you explore the device's file system.
Using of standalone version of DDMS is deprecated. (./ddms)
Android Device Monitor should be used instead.
10. AVD MANAGER
Start AVD: ./android avd
Start Emulator: ./emulator -avd <avd_name>
Start Emulator with enabled GA: ./emulator -avd <avd_name> -gpu on
Configuring Graphics Acceleration
Must have: Android SDK Tools Revision 17 or higher, Android SDK Platform API 15 - Revision 3 or higher
- create a new AVD with the Target value of Android 4.0.3 (API Level 15), revision 3 or higher.
- in the Hardware section, click New, select GPU emulation and set the value to Yes.
- Name the AVD instance and select any other configuration options.
Caution: Do not select the Snapshot: Enabled option. Snapshots are not supported for emulators with graphics acceleration enabled.
- Click Create AVD to save the emulator configuration.
Configuring Virtual Machine Acceleration
http://developer.android.com/tools/devices/emulator.html
13. MEMORY LEAKS
Install hprof converter for Eclipse
Use standalone version from http://eclipse.org/mat/downloads.php
Or use as a plugin. Go to Eclipse. Help -> Install New Software…
Paste link http://download.eclipse.org/mat/1.3/update-site/
14. MEMORY LEAKS
In case of using standalone version you need to
convert Dalvik-hprof to J2SE-hprof manually
In cmd run:
hprof-conv.exe <name of your dalvik hprof> <new name for
destination hprof>
Example: hprof-conv.exe my.app.dump.hprof my.app.converted-
dump.hprof
18. DDMS - MEMORY LEAKS
Do some more actions, play videos, open images, try to scrub in different
directions, etc. and then make heap-snapshot again. When we are ready go to
the latest histogram and click "Compare to another Heap Dump" in the dialog
choose your previous dump and click OK
19. DDMS - MEMORY LEAKS
In the new-opened view you can see increase of heap and allocated memory for
each object and for sum
20. DDMS - MEMORY LEAKS
We can see that there is no huge gain of memory and in logs we see that
memalloc periodically cleans buffer
21. DDMS - MEMORY LEAKS
Also we can go to System view and check current memory usage of device then
quit app and check again to be sure, that memory is cleared after quit.
24. MONKEY
1. Install apk to your device:
$ ./adb install ../path/to/your/app/name-of-apk.apk
2. Now we should know package of application that contains MainActivity:
$ ./aapt dump xmltree ../path/to/your/app/name-of-apk.apk AndroidManifest.xml
It was found at the begining:
A: package="com.company.android.appname"
3. Run Monkey with different parameters:
$ ./adb shell monkey -p com.company.android.appname --throttle 10 -v -v --pct-
touch 60 --pct-motion 0 --pct-syskeys 1 --hprof 5000
Explanations:
--hprof generates profiling-reports in folder data/misc
You can get it with $ ./adb pull /data/misc //Volumes/MacintoshHD2/Temp
--throttle is a timeout between actions [ms]
5000 – is a total amount of events
More Command Options here: http://developer.android.com/tools/help/monkey.html
25. USEFUL CONSOLE COMMANDS
cd android-sdk-macosx/platform-tools/
./aapt dump xmltree ../Path/to/App/apk-name.apk AndroidManifest.xml
./adb install ../Path/to/App/apk-name.apk
./adb devices
./adb -s emulator-5554 install ../Path/to/App/apk-name.apk
./adb -s 4df70f6842f34007 install ../Path/to/App/apk-name.apk
./adb kill-server and ./adb start-server
Working with device/emulator:
./adb shell am start -a com.company.android.appname/.AppMainActivity -n
com.company.android.appname/.AppMainActivity
./adb shell am force-stop -a com.company.android.appname
./adb shell am kill -a com.company.android.appname
./emulator –avd <emulator_name>
./adb shell getprop ro.build.version.release [this gives device’s Android version]
26. ANDROID MANIFEST
Get AndroidManifest.xml:
./aapt dump xmltree ../Path/to/App/app-name.apk AndroidManifest.xml
Result:
N: android=http://schemas.android.com/apk/res/android
E: manifest (line=2)
A: android:versionCode(0x0101021b)=(type 0x10)0x2
A: android:versionName(0x0101021c)="0.4.8" (Raw: "0.4.8")
A: package="com.company.android.appname" (Raw: "com.company.android.appname")
E: uses-sdk (line=4)
A: android:minSdkVersion(0x0101020c)=(type 0x10)0xe
A: android:targetSdkVersion(0x01010270)=(type 0x10)0xe
Where data is in Hex format.
Min Sdk Version is “android:minSdkVersion(0x0101020c)=(type 0x10)0xe” “0xe”
“e” 14 in decimal. 14 is API level. And appropriate Android version is 4.0
according to http://developer.android.com/about/versions/android-4.0.html
28. CAN BE HELPFUL
Set path to your tools into Environment Variables
System properties -> Advanced -> Environment Variables -> System Variables:
Simply add “;C:pathtosdktools;” into variable Path.
Now you can use tools anywhere from cmd =)