Extract app icon from apk file

40,789

Solution 1

  • 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.

Solution 2

//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

Get-apk icon

Solution 3

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.

Solution 4

Software

You can also try these GUI tools to easily extract Android app icon:

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.

APK Icon Editor

  • 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.

Solution 5

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='\([^']*\).*/\1/p") > /tmp/$$.png && preview /tmp/$$.png; }

Use it like this:

preview-android-icon /path/to/your.apk
Share:
40,789
www.jensolsson.se
Author by

www.jensolsson.se

Updated on May 24, 2020

Comments

  • www.jensolsson.se
    www.jensolsson.se over 3 years

    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.

  • www.jensolsson.se
    www.jensolsson.se about 11 years
    Thanks for the reply but unfortunately the AndroidManisfest.xml file is compiled to a binary format. If someone can find a small utility that would decompile the AndroidManifest.xml this would be a good solution.
  • www.jensolsson.se
    www.jensolsson.se about 11 years
    Thanks for the reply. I have also been thinking in these terms and I have started the work to extract the manifest decompilation part from apktool. But it would be very nice to find some tools that would do this out of the box. I was hoping there is such a tool somewhere.
  • www.jensolsson.se
    www.jensolsson.se almost 11 years
    This is not the correct solutions since you cannot determine the icon name and there can be many icons in an app. icon.png does not necessarily mean it is the app icon.
  • adrianTNT
    adrianTNT almost 11 years
    Yes, I edited my answer. I think there isn't a way to find the right one; for my personal use, I extract all files on server and list all .png files, then I select one of them.
  • Guilherme Nascimento
    Guilherme Nascimento over 4 years
    I found icon in /res/mipmap-xxxhdpi-v4/icon.png, in /res/drawable-hdpi/ only contains splash image (probably because things have changed in more current versions of Android (2019 :) ))
  • Zdenek
    Zdenek almost 3 years
    That's good advice, but many new APKs are different and this command won't work.