Android - Get package name from APK






I had to make a script that extracts the package name from an APK to uninstall it before installing it again (this is a common issue when using native libraries when Android does not replace old libraries with new ones). As you likely know, to uninstall an APK you need to know its package name. So to automate this, I decided to directly extract the package name from the APK and make a script that does this process automatically. But how to extract the package name from the APK in the first place?

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

And this is yet another reason on why I love Linux. When you go Linux, you can't go back.

Comments

Popular Posts