I am in need of extracting the app icon from an apk-file.
I just need one icon, i don’t want to extract everything else in the apk. The files are easy to get hold on, but how do I determine which icon file is the correct app-icon. I guess this is stored in the resource table? So I guess what I need is actually to read the resource table and I hope that from the resource table I can determine the icon file namne which I can then extract from the app.
I need a simple tool for this, i know about apktool that can extract the entire apk file but this is not what I want since
-
it does a lof of other stuff that I dont need (decompile, decompress other files etc)
-
it takes a lot of time to run
Is there any other tool I can use just to get hold of the icon file path?
All suggestions are appreciated
EDIT: To clarify, I am not trying to do this on the device. I am trying to do this on a PC.
aapt
tool ships with Android SDK, found under platform-tools
should give you the details you need. apktool ships with aapt.
aapt d --values badging payload.apk
Using this output, you can extract the icon file out of apk (which is a zip file).
Answer:
- Rename the .apk file to .zip
- Unzip it with a tool like 7zip
- Find the icons as png files under:
/res/drawable-hdpi/icon.png
Edit: Note that this file is not present in all apk files but in most of them.
I could not find a better solution besides extracting all .png files and picking one from the list.
Answer:
//if your apk is not installed ..only having .apk on sdcard
String APKFilePath = "mnt/sdcard/myapkfile.apk"; //For example...
PackageManager pm = getPackageManager();
PackageInfo pi = pm.getPackageArchiveInfo(APKFilePath, 0);
// the secret are these two lines....
pi.applicationInfo.sourceDir = APKFilePath;
pi.applicationInfo.publicSourceDir = APKFilePath;
//
Drawable APKicon = pi.applicationInfo.loadIcon(pm);
String AppName = (String)pi.applicationInfo.loadLabel(pm);
you can refer this link
Answer:
As to my knowledge (and according to Wikipedia as well), APK files are ZIP file formatted packages. So I think you can just use any unzip tool to unzip the apk-file and take the icon you want. For the launcher-icon, just open the AndroidManifest.xml
file and have a look at the android:icon
property of the <application>
. It probably looks something like so:
android:icon="@drawable/ic_launcher"
The icon file would then be res/drawable-<dim>/ic_launcher.png
, where <dim>
can be any of ldpi, mdpi, hdpi, xhdpi
which stand for different resolutions. The largest image would be in xhdpi
or hdpi
.
Answer:
This bash
function will extract the icon and display it with preview
. If you’re not on a mac, then you could use the display
command from ImageMagick.
preview-android-icon () { unzip -p $1 $(aapt d --values badging $1 | sed -n "/^application: /s/.*icon='\([^']*\).*//p") > /tmp/$$.png && preview /tmp/$$.png; }
Use it like this:
preview-android-icon /path/to/your.apk
Answer:
Software
You can also try these GUI tools to easily extract Android app icon:
- APK Icon Editor – simple and intuitive.
- APK Editor Studio – more advanced but still easy to use.
Description
Though the Apktool is used under the hood, the GUI front-end makes it very simple to extract or change APK icons.
The proper application icons are automatically parsed from the manifest and the internal structure, so there is no need to manually search for the needed resource files.
- Both tools help you to easily edit, replace or extract icons via user-friendly GUI.
- Both tools are available for Windows, macOS and Linux.
- Both tools are open-source (written in C++/Qt).
Disclaimer
I am the author of these tools.
Answer:
if you are novice like me you can use android app Called My APK (Google Play Link) to extract apps icons on your android phone either this app installed or you just have downloaded the apk files from outsources like apkMirror, APKpure, AppsAraby
Answer:
apktool’s source is available. Since resource extraction and code decompilation are quite different, I suspect it would be easy to modify it to remove code decompilation to minimize it to what you need.
As to determining the icon file name, you base that on the contents of AndroidManifest.xml, but you may need to account for multiple versions of the icon based on screen density, orientation, language configuration, etc.
Tags: androidandroid, file