Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I have deployed my apps .apk file on a Qualcomm device. Now due to my bad luck my laptop on which this app was developed got stolen.So i do not have my app code with me. However i have the device on which i had earlier installed my app.

So my question is, can i get my apps .apk file from this device? if yes, then please tell me how to get that.

Any help is appreciable.

Thanks, Gaurav

share|improve this question

2 Answers 2

If you know the installed file name of the apk (which on some devices may be myapp-1.apk or myapp-2.apk rather than just myapp.apk) you can directly access that as an ordinary user including the one adb runs as on a secured device, so you should be able to adb pull it. But if you don't know the installed apk name, you cannot browse the /data/app directory without being root or aid_system.

It might be worth just guessing at the installed name - try it plain, try it with the -1.apk, and the -2.apk, etc.

There may be another way: I believe the following will work on a secured device but don't have one in front of me at the moment to test it.

EDIT: New idea for determining exact APK file name

1) adb pull /data/system/packages.xml

2) Look through it for your application's codePath entry

3) adb pull that

EDIT: With regard to the old idea below, Matthew discovered that while the per-process files under /proc have read permission on a secured device, they are empty when read by an unprivileged uid other than that of their owner. So this won't work.


1) Get your app running. You'll also need a machine with adb.

2) type

adb shell ps 

and look for the line with your app's name:

app_1     11959 907   112984 27580 ffffffff afd0c5bc S com.clevername.myapp

3) take the number in the second column which is the process id, and view it's virtual memory map, in this case I would type

adb shell cat /proc/11959/maps

and look for a line where it has mapped its own apk file into memory

43e9c000-43ea3000 r--s 001f4000 b3:06 15393      /data/app/com.clevername.myapp-1.apk

4) That's the file name you would need to adb pull

adb pull /data/app/com.clevername.myapp-1.apk .

Examination of the directory permissions in /proc suggests this should work for an unprivileged user, my apologies if it does not. If you are familiar with the usage of 'grep' you can use that to avoid manually scanning the output.

Addendum: I'm not really sure what the story on apps installed to the SD card is.

share|improve this answer
    
I just tried on my secure device; adb shell cat /proc/####/maps returns nothing, unfortunately. –  Matthew Read May 17 '11 at 17:46
    
@Matthew... odd, I'm simulating the secure case and seeing most of the files in proc have zero size, but are readable. Before I'd only checked that they would have read permissions. Maybe it's done by nulling them rather than permissions so that /proc reading tools don't get a constant stream of access errors. Oh well... guessing at installed apk name variant may be the best. –  Chris Stratton May 17 '11 at 17:57
    
My apk filename was all crazy and unguessable, but using packages.xml worked to figure out the real name. :) –  paleozogt Nov 16 '11 at 16:27

It should be located at /data/app/. You can access that directly if you have root. If not, you will have to use adb pull. For example:

adb pull /data/app/myapp.apk C:\backup\myapp.apk

More info on adb: http://developer.android.com/guide/developing/tools/adb.html

share|improve this answer
    
Thanks Matthew. I will check this and revert back! –  GamDroid May 17 '11 at 15:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.