After android installs an application from the Marketplace, does it keep the .apk file?
Is there a standard location where Android would keep such files?
You can use package manager (pm) over adb shell to list packages:
adb shell pm list packages | sort
and to display where the .apk file is:
adb shell pm path com.king.candycrushsaga
package:/data/app/com.king.candycrushsaga-1/base.apk
And adb pull to download the apk.
adb pull data/app/com.king.candycrushsaga-1/base.apk
Preinstalled applications are in /system/app folder. User installed applications are in /data/app. I guess you can't access unless you have a rooted phone.
I don't have a rooted phone here but try this code out:
public class Testing extends Activity {
private static final String TAG = "TEST";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
File appsDir = new File("/data/app");
String[] files = appsDir.list();
for (int i = 0 ; i < files.length ; i++ ) {
Log.d(TAG, "File: "+files[i]);
}
}
It does lists the apks in my rooted htc magic and in the emu.
If you just want to get an APK file of something you previously installed, do this:
Get AirDroid from Google Play
Access your phone using AirDroid from your PC web browser
Go to Apps and select the installed app
Click the "download" button to download the APK version of this app from your phone
You don't need to root your phone, use adb, or write anything.
There is no standard location, however you can use the PackageManager to find out about packages and the ApplicationInfo class you can get from there has various information about a particular package: the path to its .apk, the path to its data directory, the path to a resource-only .apk (for forward locked apps), etc. Note that you may or may not have permission to read these directories depending on your relationship with the other app; however, all apps are able to read the resource .apk (which is also the real .apk for non-forward-locked app).
If you are just poking around in the shell, currently non-forward-locked apps are located in /data/app/.apk. The shell user can read a specific .apk, though it can't list the directory. In a future release the naming convention will be changed slightly, so don't count on it remaining the same, but if you get the path of the .apk from the package manager then you can use it in the shell.
Preinstalled Apps are typically in /system/app and user installed apps are in /data/app.
You can use "adb pull", but you need to know the full path of the APK file. On the emulator, you can get a directory listing using "adb shell" + "ls". But on an android device, you will not be able to do that in "/data" folder due to security reasons. So how do you figure out the full path of the APK file?
You can get a full list of all apps installed by writing a program that queries the PackageManager. Short code snippet below:
PackageManager pm = getPackageManager();
List<PackageInfo> pkginfo_list = pm.getInstalledPackages(PackageManager.GET_ACTIVITIES);
List<ApplicationInfo> appinfo_list = pm.getInstalledApplications(0);
for (int x=0; x < pkginfo_list.size(); x++){
PackageInfo pkginfo = pkginfo_list.get(x);
pkg_path[x] = appinfo_list.get(x).publicSourceDir; //store package path in array
}
You can also find apps that will give such info. There are lots of them. Try this one (AppSender).
Install from marketplace
It's the behavior of marketplace whether to keep the apk after installation. Google play doesn't keep the apk after the installation. Other third-party marketplaces might have the different behaviors.
Install from development/debug tool (adb, eclipse, android studio)
When we install the apk from debug tool, directly invoke adb install or from eclipse/android studio, the apk will be transferred (adb push) to a public read and writable directory, usually /data/local/tmp/. After that, the tool will use the pm command to install, it will delete the temporary apk in /data/local/tmp/ after the successful installation.
We could get these information from debug output like following.
$ adb install bin/TestApplication.apk
3155 KB/s (843375 bytes in 0.260s)
pkg: /data/local/tmp/TestApplication.apk
Success
How system keeps the apk
Of course the system have to store all apks somewhere. There are three places for the system to keep the apks based on the different types of apks:
for stock app
Those are usually shipped in device by manufacture, including core app for system running and google service, you can find them under directory /system/app and /system/priv-app.
user installed app
Most of the apks fall into this category. These apks are usually installed from marketplace by users or by adb install without -s option. You can find them under the directory /data/app for a rooted device.
app on sdcard
If the apk enable its install location in sdcard with android:installLocation="auto" in its manifest, the app can be moved to sdcard from system's app manager menu. These apks are usually located in secure folder of sdcard /mnt/sdcard/asec.
Anther way to force the install location to sdcard is using the command adb install -s apk-to-install.apk.
As a note, the files for pre-installed app are not in a single .apk file anymore. There is a folder containing files for every pre-installed app in the directory /system/app or /system/priv-app for the newest android release.
If you're looking for the path of a specific app, a quick and dirty solution is to just grep the bugreport:
$ adb bugreport | grep 'dir=/data/app'
I don't know that this will provide an exhaustive list, so it may help to run the app first.
You can pull apps with ADB. They are in /data/App/, I believe.
adb pull (location on device) (where to save)
Note that you have to root your phone to pull copy protected apps.
In /data/app but for copy protection I don't think you can access it.
If you are rooted, download the app Root Explorer. Best File manager for rooted users.
Anyways, System/app has all the default apks that came with the phone, and data/apk has all the apks of the apps you have installed. Just long press on the apk you want (while in Root Explorer), get to your /sdcard folder and just paste.
data/app
system/app
system/priv-app
mnt/asec (when installed in sdcard)
You can pull the .apks from any of them:
adb pull /mnt/asec
Use this to list all .apks under /data/app/
adb bugreport | grep 'package name="' | grep 'codePath="/data' | cut -d'"' -f4
.apk files can be located under /data/app/ directory. Using ES File Explorer we can access these .APK files.
if you are using eclipse goto DDMS and then file explorer there you will see System/Apps folder and the apks are there
When i installed my app on emulator, it showed my the .apk file in
data/app
Then I used
ls data/app //to see if it exists or
not
After you install your app just use ls command vie shell and check desired directory but it depends what kind of application you are trying to install. I used this method to Install
Point if any thing is wrong.
Another way to get the apks you can't find, on a rooted device is with rom tool box.
Make a backup using app manager then go to storage/emulated/appmanager and check either system app backup or user app backup.
To find an apk, download and Install the Bluetooth App Sender from Play store. Once installation completes open the Bluetooth App Sender. It will show all the apps (.apk) installed in your device, then you can easily transfer the app to your PC through Bluetooth.
As opposed to what's written on the chosen answer, you don't need root and it is possible to get the APKs of the installed apps, which is how I've done it on my app (here). Example:
List<PackageInfo> packages=getPackageManager().getInstalledPackages(0);
Then, for each of the items of the list, you can access packageInfo.applicationInfo.sourceDir, which is the full path of the APK of the installed app.
Install Total Commander.
Open Installed apps on the main page.
Well I came to this post because I wanted to reinstall some app I liked much.
If this is your case, just go to Google Play, and look for My Apps, the tab All, and you will find a way to reinstall some app you liked. I faced a problem that I could not find by search one app, but it was there in My apps so I could reinstall in my new mobile ;)
Related
I'm trying to extract .apk files of my apps installed from blue stacks player using adb .I am successful in getting the .apk's of files that are present in the location "/system/app". Below is the command that i gave from my command line
adb pull /system/app C:\xyz\ffff
However,When i am trying to get the .apk of the apps that are present in the location "/data/app" it says
"0 files pulled"
However,I'm pretty much sure it has got over 10 apps.
Any help would be highly helpful
1.Download 'apkextractor' app from playstore and install it in your bluetack, This application can extract the applications installed in bluestack
2.To access this .apk files you need any filemanager, And go to extractedApk directory
3.To move apk files from bluestack to pc folder, Move the .apk files from 'extractedApk' to 'windows/pictures' folder
This screenshot will help you
In the latest versions of Android, APKs are no longer simply stored in the /data/app folder.
To get the list of installed packages (and their paths) run the following:
adb shell pm list packages -f
This will show you packages and paths to the APKs. Like this:
package:/data/app/com.android.chrome-2/base.apk=com.android.chrome
Here, you can see the APK resides at /data/app/com.android.chrome-2/base.apk
Running adb pull /data/app/com.android.chrome-2/base.apk works.
You need to do this for each APK shown in the package list. On non-rooted devices, you cannot search for APKs in the /data/app folder because adb does not have permission to view the contents of folders in this location.
I have installed an Android app on my phone which I have created myself on java. The App got successfully installed on the device but I am not able to locate the package where it has installed.
How to find the path of the installed application?
You will find the application folder at:
/data/data/"your package name"
you can access this folder using the DDMS for your Emulator. you can't access this location on a real device unless you have a rooted device.
System apps installed /system/app/ or /system/priv-app. Other apps can be installed in /data/app or /data/preload/.
Connect to your android mobile with USB and run the following commands. You will see all the installed packages.
$ adb shell
$ pm list packages -f
An application when installed on a device or on an emulator will install at:
/data/data/APP_PACKAGE_NAME
The APK itself is placed in the /data/app/ folder.
These paths, however, are in the System Partition and to access them, you will need to have root. This is for a device. On the emulator, you can see it in your logcat (DDMS) in the File Explorer tab
By the way, it only shows the package name that is defined in your Manifest.XML under the package="APP_PACKAGE_NAME" attribute. Any other packages you may have created in your project in Eclipse do not show up here.
->List all the packages by :
adb shell su 0 pm list packages -f
->Search for your package name by holding keys "ctrl+alt+f".
->Once found, look for the location associated with it.
The package it-self is located under /data/app/com.company.appname-xxx.apk.
/data/app/com.company.appname is only a directory created to store files like native libs, cache, ecc...
You can retrieve the package installation path with the Context.getPackageCodePath() function call.
/data/data/"your app package name "
but you wont able to read that unless you have a rooted device
I'm trying to extract the APK file of an installed Android app WITHOUT root permissions.
I thought that this was impossible, because all APK files for non-system-apps are located in /data/app, and accessing this folder requires root permission. Then I found that there are numerous apps in the Google Play store that seem to have access to the APK files even on non-rooted devices.
Can someone tell me how this is possible? Aren't there backup apps which backup the APK files without root?
Accessing /data/app is possible without root permission; the permissions on that directory are rwxrwx--x. Execute permission on a directory means you can access it, however lack of read permission means you cannot obtain a listing of its contents -- so in order to access it you must know the name of the file that you will be accessing. Android's package manager will tell you the name of the stored apk for a given package.
To do this from the command line, use adb shell pm list packages to get the list of installed packages and find the desired package.
With the package name, we can get the actual file name and location of the APK using adb shell pm path your-package-name.
And knowing the full directory, we can finally pull the adb using adb pull full/directory/of/the.apk. The APK file gets stored to the directory from which you run your console.
Credit to #tarn for pointing out that under Lollipop, the apk path will be /data/app/your-package-name-1/base.apk
Android appends a sequence number to the package name to produce the final APK file name (it's possible that this varies with the version of Android OS). The following sequence of commands works on a non-rooted device:
Get the full path name of the APK file for the desired package.
adb shell pm path com.example.someapp
This gives the output as: package:/data/app/com.example.someapp-2.apk.
Pull the APK file from the Android device to the development box.
adb pull /data/app/com.example.someapp-2.apk
The location of APK after successful pulling will be at ../sdk/platform-tools/base.apk on your pc/laptop.
On Nougat(7.0) Android version run adb shell pm list packages to list the packages installed on the device.
Then run adb shell pm path your-package-name to show the path of the apk.
After use adb to copy the package to Downloads adb shell cp /data/app/com.test-1/base.apk /storage/emulated/0/Download.
Then pull the apk from Downloads to your machine by running adb pull /storage/emulated/0/Download/base.apk.
check the list of installed apk's (following command also list the path where it is installed and package name).
adb shell pm list packages -f
use adb pull /package_path/package name /path_in_pc
(package path and package name one can get from above command 1.)
I got a does not exist error
Here is how I make it works:
adb shell pm list packages -f | findstr zalo
package:/data/app/com.zing.zalo-1/base.apk=com.zing.zalo
adb shell
mido:/ $ cp /data/app/com.zing.zalo-1/base.apk /sdcard/zalo.apk
mido:/ $ exit
adb pull /sdcard/zalo.apk Desktop
/sdcard/zalo.apk: 1 file pulled. 7.7 MB/s (41895394 bytes in 5.200s)
When you have Eclipse for Android developement installed:
Use your device as debugging device. On your phone: Settings >
Applications > Development and enable USB debugging, see
http://developer.android.com/tools/device.html
In Eclipse, open DDMS-window: Window > Open Perspective > Other... >
DDMS, see http://developer.android.com/tools/debugging/ddms.html
If you can't see your device try (re)installing USB-Driver for your
device
In middle pane select tab "File Explorer" and go to system > app
Now you can select one or more files and then click the "Pull a file
from the device" icon at the top (right to the tabs)
Select target folder - tada!
Open ES explorer -> push Menu button at the left upper corner (three horizontal stripes) -> in the Libraries section choose APPs.
Thus, you get the list of all the user apps. Find your app and select it with long pushing on it. Then press "More" in the right low corner and choose "Send". Then you can use different options, e.g. you can choose "ES Save To" in order to save the .apk file to your home directory or anywhere else.
Obtaining an APK file of an installed app is possible via the free and open-source Ghost Commander app, which is available on both F-Droid and the Play Store.
In the Ghost Commander app, go to Apps, then simply long-tap an app from the list and choose Copy. The .apk file will be available in the other file panel; you can put it wherever you want.
Note that, since Ghost Commander is a two-panel file manager, you first have to use the other panel and open a folder there (which is where we want to copy the apk file into). Then, go to the other panel and go to Apps there.
(If you don't see 'Apps', first tap the arrow and select Home.)
Links:
https://f-droid.org/packages/com.ghostsq.commander/
https://sourceforge.net/projects/ghostcommander/
https://play.google.com/store/apps/details?id=com.ghostsq.commander
I found a way to get the APK's package name in a non-root device.
it's not so elegant, but works all the time.
Step 1: on your device, open the target APK
Step 2: on PC cmd window, type this commands:
adb shell dumpsys activity a > dump.txt
because the output of this command is numerous, redirect to a file is recommended.
Step 3: open this dump.txt file with any editor.
for device befor Android 4.4:
the beginning of the file would be looked like this:
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
Main stack:
* TaskRecord{41aa9ed0 #4 A com.tencent.mm U 0}
numActivities=1 rootWasReset=true userId=0
affinity=com.tencent.mm
intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10600000 cmp=com.tencent.mm/.ui.LauncherUI}
realActivity=com.tencent.mm/.ui.LauncherUI
askedCompatMode=false
lastThumbnail=null lastDescription=null
lastActiveTime=19915965 (inactive for 10s)
* Hist #9: ActivityRecord{41ba1a30 u0 com.tencent.mm/.ui.LauncherUI}
packageName=com.tencent.mm processName=com.tencent.mm
the package name is in the 3rd line, com.tencent.mm for this example.
for Android 4.4 and later:
the dumpsys output has changed a little.
try search "Stack #1", the package name would be very close below it.
Also, search "baseDir", you will find the full path of the apk file!
One line command, with separated download to paths by packages
SEARCH_APP="minecraft" && PKGS=$(adb shell pm list packages | grep ${SEARCH_APP}) && for PKG in ${PKGS}; do PKG=${PKG#*:} && mkdir -p ${SEARCH_APP}/${PKG} && PKG_FILES=$(adb shell pm path ${PKG}) && for PKG_FILE in ${PKG_FILES}; do PKG_FILE=${PKG_FILE#*:} && adb pull $PKG_FILE ${SEARCH_APP}/${PKG}; done; done
Or you can get 'Bluetooth File Transfer' from Google Play and set the home folder to /system/ . Then you can even go to / .
I am making one app on Android and I have no idea what is doing one file which is installed after app installation. This file is quite big (this is about this same size as installed apk - even after uninstall ~ 5MB) so this is the reason of my question.
he file is set in data/local/tmp/'name of my apk'.apk
What is it and when it is deleted, because when I'm testing my app on emulator and uninstall it then it still exists.
EDIT AND ANSWERS:
I am not sure of my app is using tmp files. The only file or resource my app is using is movie placed in resources folder which is around 5MB. Deleting this file after app uninstall brings back free space. Before uninstall no. But I want to have deleted it melodramatically or not created at all because this file makes me app 2 times bigger.
The files in there are temporary files and you can safely delete them.
For instance, these are created when you:
Install an APK trought the command line with adb install (the temporary file will have the same name as the original file);
Install / Run an application through Android Studio (the temporary file will have the application package name).
To easily list all the temporary files, you can use the following command:
adb shell ls /data/local/tmp
To remove all of them, you can just use the following command:
adb shell rm /data/local/tmp/*
The .apk is your application. You'd be Sad if Android deleted it behind your back :)
http://developer.android.com/guide/developing/building/index.html#detailed-build
http://www.ibm.com/developerworks/xml/library/x-androidstorage/index.html
This file is the uploaded apk on emulator. Like normal file upload on device.
My apk file size is 2MB. First time installing the apk file in the device there is no problem.
Suppose some changes in the application after that generated the new apk file. I am try to install the new apk file in the same device then it shows some message first uninstall the previous one(i.e. , same application) in the device. But small apk files, I am not facing this problem.
Is it possible to install the new apk file without uninstall the old one?
It is not connected with apk size but with the fact that the old apk was signed with different key than the new one. So you must uninstall it before installing new application but you will have to do it only once.
Use this command in command prompt:
adb install -r yourapplicationname.apk
It is because of the Low Internal Memory size. Uninstall applications that are not useful. Try it after that. If u don't want to uninstall any application then you can install your APK file directly to the SD Card. Because of that your problem is solve.
I give you the hint how to Install APK on SD Card..
First create Emulator with SD Card Support and SD Card size - 1024 MiB.
After that U can Install your apk file on to sd card directly using command prompt.
Type below code in command prompt to install:
adb install -s name.apk
You need to change the package name of your application otherwise it is not possible to install two applications with same package name and different keys.