11 February 2013

How to decompile apk from Play Store

No comments:

This is how you can decompile an application you have installed on your phone.

My phone is rooted, uses RootBox 3.5 and has BusyBox installed. You may need to have that too if you want to follow my steps completly.

Let's start:

1. Install application from market

2. Download apk to computer

First you need to locate the apk on the phone.

Connect to the phone:

 adb shell

Find the apk in the folder the apk are downloaded to. It is ussualy in '/data/app/' or '/system/app/'. The apk is called as the id from the Play Store, for example 'com.something.someapp.apk'. You can see this in the url from Play.

Next you need to pull it to the computer. Once you have located the apk and know it's name exit adb.

On your PC execute:

 adb pull /data/app/com.something.someapp.apk 

3. Transform apk to jar

I use dex2jar
dex2jar-0.0.9.11/d2j-dex2jar.sh com.something.someapp.apk

4. See the code inside the jar

I use Java Decompiler

Just open the program and open the jar.

5. Get the resources

You can just unzip the apk. This will allow you to get the images but not the xml and layouts.

Instead you could use android-apktool. After you download and install it, just run:
apktool d com.something.someapp.apk

I know it's not very complicated but I needed a place to put this so I can remember the details.

Enjoy!

Update: Intellij 12 + Android Annotations 2.7 + maven

3 comments:
This is my previous post updated for the new versions of intelliJ Idea 12 and Android Annotations 2.7

1. Create your project with Android Maven Plugin

Read the GettingStarted

You can run this command to get the basic structure:

mvn archetype:generate \
  -DarchetypeArtifactId=android-quickstart \
  -DarchetypeGroupId=de.akquinet.android.archetypes \
  -DarchetypeVersion=1.0.9 \
  -DgroupId=com.tagonsoft \
  -DartifactId=ExampleApp

Add/Edit the dependency to android:

With android from central mvn repository:

  com.google.android
  android
  4.1.1.4

Or with android from maven-android-sdk-deployer:

  android
  android
  4.2_r1
  provided

Run 'mvn idea:idea' to get the basic idea project to start with.

2. Add AndroidAnnotations to maven pom.xml

  

  com.googlecode.androidannotations
  androidannotations
  2.7.1
  provided



  com.googlecode.androidannotations
  androidannotations-api
  2.7.1
                                          

3. Configure Idea compiler

Like so:
I couldn't get it to work with processor from classpath, so I use the path from maven repo. For intelliJ Idea 12 you have to add 3 jars like so (the path are from my own mvn repo):
/work/libs/mvnrepo/com/googlecode/androidannotations/androidannotations/2.7.1/androidannotations-2.7.1.jar:/work/libs/mvnrepo/com/googlecode/androidannotations/androidannotations-api/2.7.1/androidannotations-api-2.7.1.jar:/work/libs/mvnrepo/com/sun/codemodel/codemodel/2.4.1/codemodel-2.4.1.jar

The jars are androidannotations-2.7.1.jar, androidannotations-api-2.7.1.jar and codemodel-2.4.1.jar. The separator is ':'.

Add as processor FQ name:

com.googlecode.androidannotations.AndroidAnnotationProcessor

4. Tweak your module to regenerate R file in the new location:


I use <project path> + /target/generated-sources/r
Hope someone else finds this useful. Feel free to add or correct me.