androidwindowsaapt

aapt dump not producing the output needed


Hey all I am trying to figure out why the following command does not produce the needed output:

aapt dump badging c:/adb/apks/ftp/ftp.apk " | sed -r s/package: name='([a-z0-9.]*)'.*/\1/"

This just produces a lot of text:

package: name='com.medhaapps.wififtpserver' versionCode='74' versionName='1.9.5' compileSdkVersion='28' compileSdkVersionCodename='9'
sdkVersion:'16'
targetSdkVersion:'28'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission-sdk-23: name='android.permission.ACCESS_COARSE_LOCATION'
application-label:'WiFi FTP Server'
......ETC ETC.....

Shouldn't this just produce:

package: name='com.medhaapps.wififtpserver'

Solution

  • aapt dump badging c:/adb/apks/ftp/ftp.apk " | sed -r s/package: name='([a-z0-9.]*)'.*/\1/"
    

    The command you were trying to use has two problems:

    1. You added double quotes around the second part of the command, which changes the command.
    2. You are on Windows and the command is designed to be executed on Linux.

    The original working command without quotes is

    aapt dump badging c:/adb/apks/ftp/ftp.apk  | sed -r s/package: name='([a-z0-9.]*)'.*/\1/
    

    It combines the two programs aapt from Android SDK and the standard Linux tool Stream EDitor sed. As you are on Windows this command is not available by default.

    The easiest way to get a Windows version of sed is install the version tool GIT CSM (the official open source version). It provides several Windows versions of standard Linux programs like sed. On a standard installation you will sind an sed.exe in C:\Program Files\Git\usr\bin. So just append that directory to your PATH and you will have a working sed version ready for the command.