How to decompile apk from Play Store

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

Groovy way to see if thread execution had errors

I had to write a script that did something and for a faster run I decided to use threads.
I needed to start a thread to do some task and then to be able to check that it had finished without an error/exception.
In Java if the code executed in a new thread throws an error, it doesn't matter that much, it just executes the next instruction after thread.join().
Some solutions found on the internet were
  • to put all the code inside the thread in a try-catch block and in the catch block populate a map with the thread name and status. Then you could get the status by querying statusMap[threadName]
  • add a status status field to your class witch is a subclass of Thread. Then you do the same thing as above and in the catch block modify the status to failed (status is successfull in the begining). You get get the status by thread.status
Luckily in  groovy we have dynamic object behaviour.
So my solution is to add a new field to the Thread class, and use Thread.setDefaultUncaughtExceptionHandler to populate it.
It looks something like
Thread.metaClass.failed = false

Thread.setDefaultUncaughtExceptionHandler(
        {t, ex ->
          t.failed = true
        } as Thread.UncaughtExceptionHandler)

def th= Thread.start {
  println ' in thread 1'
  throw new RuntimeException("thread exception")
  println ' in thread 2'

}
th.join()

assert th.failed

And now I can see if any exception/error has been thrown. And all the threads I start will have this property.

Comments

  1. Cool hack, I did that in java by forcing the thread implementation class to implement a life cycle interface so that, if there's any error it'd give a callback to the interface.

    But this one's lot of more 'groovier', I liked it.. thanks for the post.

    ReplyDelete

Post a Comment

Popular posts from this blog

Ways to map and query many-to-many in GORM

Update: Intellij 12 + Android Annotations 2.7 + maven

How to decompile apk from Play Store