-
Notifications
You must be signed in to change notification settings - Fork 249
Tutorial2
I want to get the return value when my application calls an Android API. In this case, we use FingerPaint in ApiDemo app from Android SDK as an example to show how we get the return value of android.view.MotionEvent.getX() when the application calling the method
- create an eclipse project for ApiDemo (sdk\samples\android-7\ApiDemos)
- build it and get the apk file in bin folder, e.g. sdk\samples\android-7\ApiDemos\bin\ApiDemos.apk
- because we are using the sample app from the SDK, we just use the corresponding android.jar to solve the class path, e.g. sdk\platforms\android-7\android.jar
-
launch the ApkAnalyser
-
File->Settings
Configure ADB executable path in ApkAnalyser, e.g. C:\android-sdk-windows\tools\adb.exe
-
File->Set path
Add android.jar, the file you get from Step 2
Add ApiDemos.apk, the file you get from Step 1
- File->Analyse...
Now, you may do any Dalvik Bytecode Injections as you want.
In this case, we just need the return value of android.view.MotionEvent.getX()
The injection should be '''Print calls to references(with return value)'''
- Right click "android.view.MotionEvent.getX()" method -> Print calls to references(with return value)
- Modification->Perform bytecode modification
Now there should be a summary of all the class modified and the new APK file
- Prepare the phone. Start emulator or connect your device via usb cable.
Make sure your phone is the only one which connect to the ADB (you may check it with "adb devices"), because there is a limitation that ApkAnalyser only support one device, see Trouble Shooting
-
Click "Install and run", the modified app will be installed and launched automatically.
-
In this case, just launch "API Demos" -> "Graphics" -> "FingerPaint"
-
Click "S" button in the Console to remove all the outputs except our logs (in TAG "APKANALYSER")
-
You may touch the screen to see the logs, here is a snapshot