Posts mit dem Label Android werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Android werden angezeigt. Alle Posts anzeigen

Dienstag, 28. August 2018

Decompiling an Android APK file

I recently needed to look into another Android app to see how they implemented some strange UI behaviour. There are a few steps neccessary to get the source code of an app.


  1. Download the APK from the device.
  2. Convert the APK file to a JAR
  3. Decompile the JAR

Download the APK from the device


This can be done using the Android SDK platform tools. Go to your SDK directory and find platform-tools/adb.

If you don't know where your application is installed on your device follow these instructions:

Type 

adb shell

This gives you a Linux shell on your device. Now type:

pm list packages -f

This will give you a list of all your installed applications and the paths where they are located in the filesystem.

Exit the shell and download the APK via:

adb pull <Path to the APK file on the device>

Now you can find the APK file in your current directory.

Convert the APK file to a JAR


Now we use the dex2jar tool to convert the Dalvik executable files into class files inside a JAR. Download the tool from the github repository and run

sh d2j-dex2jar.sh -f ~/path/to/apk_to_decompile.apk

This creates the JAR archive in the current directory.

Decompile the JAR


Now we can use the Java Decompiler to view the contents of the JAR archive. Just open the JAR archive in the Decompiler and browse the classes.


Mittwoch, 15. August 2012

Android: Install USB drivers for HP Touchpad

If you have a HP Touchpad running CyanogenMod Android, you can use it to develop and test applications on the native device. But before you can use the tools from the Android SDK on a Windows PC, you have to install the USB drivers.

The Android SDK provides USB drivers for Windows in <sdk-directory>/extras/google/usb-drivers. But those drivers don't include the needed information to identifiy a CyanogenMod Android. CyanogenMod has a patched android_winusb.inf file and the instructions on how to install it available in their wiki.

The patched driver information file does not contain information for the HP Touchpad. You have to patch the patched INF file again for the Touchpad.

So here are the steps needed to connect the Touchpad to a Windows PC to start developing/debugging:


1. Turn on MTP, which is disabled by default, on the Touchpad.
Go to Settings -> Storage -> click on the three small squares in the upper right corner -> USB computer connection -> enable Media Device (MTP)
2. Add HP Touchpad Vendor and Product IDs to the INF file
Edit the android_winusb.inf either from the CyanodgenMod wiki or the original file from the Android SDK. Add these lines at the end of the sections for [Google.NTx86] and [Google.NTamd64].

; HP TouchPad
%SingleAdbInterface%    = USB_Install, USB\VID_0BB4&PID_6860&REV_0227&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_0BB4&PID_6860&MI_01


3. Update driver in Windows Device Manager
Open the Device Manager in Windows, selection the unknown USB device and update drivers. Select the android_winusb.inf file you just modified.