How do I get an apk file from an Android device?
Use adb. With adb pull you can copy files from your device to your system, when the device is attached with USB.
Of course you also need the right permissions to access the directory your file is in. If not, you will need to root the device first.
If you find that many of the APKs are named "base.apk" you can also use this one line command to pull all the APKs off a phone you can access while renaming any "base.apk" names to the package name. This also fixes the directory not found issue for APK paths with seemingly random characters after the name:
for i in $(adb shell pm list packages | awk -F':' '{print $2}'); do
adb pull "$(adb shell pm path $i | awk -F':' '{print $2}')"
mv base.apk $i.apk &> /dev/null
done
If you get "adb: error: failed to stat remote object" that indicates you don't have the needed permissions. I ran this on a NON-rooted Moto Z2 and was able to download ALL the APKs I did not uninstall (see below) except youtube.
adb shell pm uninstall --user 0 com.android.cellbroadcastreceiver <--- kills presidential alert app!
(to view users run adb shell pm list users)
This is a way to remove/uninstall (not from the phone as it comes back with factory reset) almost ANY app WITHOUT root INCLUDING system apps (hint the annoying update app that updates your phone line it or not can be found by grepping for "ccc")
How do I get the APK of an installed app without root access?
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
Where can I find the .apk file on my device, when I download any app and install?
There is an app in google play known as MyAppSharer. Open the app, search for the app that you have installed, check apk and select share. The app would take some time and build the apk. You can then close the app. The apk of the file is located in /sdcard/MyAppSharer
This does not require rooting your phone and works only for apps that are currently installed on your phone
Generate Apk file from aab file (android app bundle)
By default, the IDE does not use app bundles to deploy your app to a
local device for testing
Refer bundletool command
For Debug apk command,
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
For Release apk command,
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
--ks=/MyApp/keystore.jks
--ks-pass=file:/MyApp/keystore.pwd
--ks-key-alias=MyKeyAlias
--key-pass=file:/MyApp/key.pwd
Edit:
I have been using following commands while testing my release build for aab(I hope it helps others too):
Download
bundletool
jar file from Github Repository (Latest release > Assets > bundletool-all-version.jar file). Rename that file tobundletool.jar
Generate your aab file from Android Studio eg: myapp-release.aab
Run following command:
java -jar "path/to/bundletool.jar" build-apks --bundle=myapp-release.aab --output=myapp.apks --ks="/path/to/myapp-release.keystore" --ks-pass=pass:myapp-keystore-pass --ks-key-alias=myapp-alias --key-pass=pass:myapp-alias-pass
myapp.apks
file will be generatedMake sure your device is connected to your machine
Now run following command to install it on your device:
java -jar "path/to/bundletool.jar" install-apks --apks=myapp.apks
Edit 2:
If you need to extract a single .apk
file from the .aab
file, you can add a extra param --mode=universal
to the bundletool
command:
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks \
--mode=universal \
--ks=/MyApp/keystore.jks \
--ks-pass=file:/MyApp/keystore.pwd \
--ks-key-alias=MyKeyAlias \
--key-pass=file:/MyApp/key.pwd
and execute
unzip -p /MyApp/my_app.apks universal.apk > /MyApp/my_app.apk
this will generate a single a /MyApp/my_app.apk
file that can be shared an installed by any device app installer
How to install APK from PC?
adb install <path_to_apk>
http://developer.android.com/guide/developing/tools/adb.html#move
how can generate apk file from installed android application?
All installed APKs are located in /data/app/, but you can see this if you have rooted device
If you don't wants to root your device then there are many application available in market such as MyAppSharer
MyAppSharer is available on google play store.
Download MyAppSharer
The APKs will goes in /sdcard/MyAppSharer
get APK of installed app with adb command
Pull the APK file from the Android device to the development box by setting destination path.
adb pull /data/app/com.facebook.katana-2/base.apk path/to/desired/destination
or use,
adb shell cat /data/app/com.facebook.katana-2/base.apk > app.apk
Related Topics
How to Open the "Front Camera" on the Android Platform
Android - Cancel Asynctask Forcefully
Android - Android.View.Inflateexception: Binary Xml File Line #8: Error Inflating Class Fragment
How to Send String from One Activity to Another
Set Icon For Android Application
How to Display a List View in an Android Alert Dialog
How to Get the Width and Height of an Android.Widget.Imageview
Android Spinner: Get the Selected Item Change Event
How to Delete an Sms in Android Before It Reaches the Inbox
Android Studio Add External Project to Build.Gradle
How to Include *.So Library in Android Studio
Check Android Application Is in Foreground or Not
Open Application After Clicking on Notification
Android Background Music Service
Android Difference Between Two Dates