Encode/Decode AndroidManifest.xml inside APK

46,029

Solution 1

You may use apktool again to create a new APK file including your changed AndroidManifest.xml.

First, decompile the APK file:

java -jar apktool.jar decode app.apk app

Then modify the files you want in the app directory and recompile it back into a new APK:

java -jar apktool.jar build app app_new.apk

aapt must be on our PATH or use the --aapt option to specify the location of the executable. Otherwise apktool will fail when rebuilding the APK.

Note: The rebuilt APK is neither signed nor zipaligned, just repackaged. Take a look at this website for details about signing and aligning your new APK.

Solution 2

Use appt for android-sdk (ex:- /build-tools/27.0.3/aapt )

./aapt d xmltree ./debug.apk  AndroidManifest.xml

N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=1)
    A: android:versionCode(0x0101021b)=(type 0x10)0x1
    A: android:versionName(0x0101021c)="1.0" (Raw: "1.0")
    A: package="com.example.activity" (Raw: "com.example.activity")
    E: uses-sdk (line=6)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0x8
      A: android:targetSdkVersion(0x01010270)=(type 0x10)0xf
    E: application (line=8)
      A: android:label(0x01010001)=@0x7f030000
      A: android:icon(0x01010002)=@0x7f020000
      E: activity (line=10)
        A: android:label(0x01010001)=@0x7f030000
        A: android:name(0x01010003)=".SampleActivity" (Raw: ".SampleActivity")
        E: intent-filter (line=12)
          E: action (line=13)
            A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
          E: category (line=14)
            A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")

This link might help http://elinux.org/Android_aapt

Another one tool for "AXMLPrinter" google source link https://code.google.com/archive/p/android4me/downloads

java -jar ./AXMLPrinter2.jar ./debug.apk_FILES/AndroidManifest.xml

Share:
46,029

Related videos on Youtube

Soheil Setayeshi
Author by

Soheil Setayeshi

Master of software engineering from IUST Java/Android Developer

Updated on September 09, 2020

Comments

  • Soheil Setayeshi
    Soheil Setayeshi over 3 years

    I'm using ApkTool to decode AndroidManifest.xml inside an APK file and it works perfectly but how can I encode it again ,the same way it was encoded before, after applying some changes? For example (in my case) changing the app label.

    • Simon
      Simon almost 11 years
      Ask the developer for the original code or download the source. If you are reverse engineering someone else's code, then no help here.
    • Soheil Setayeshi
      Soheil Setayeshi almost 9 years
      @Simon dude I was that someone else in this case cause I was just trying create an app-generator from a template "apk" file that I wrote before and trying change its data from outside and sign it again ;)
  • Mikaël Mayer
    Mikaël Mayer about 9 years
    Note that in version 2.0.0 of ApkTool, either you do not specify the "app" directory or you introduce it using the option -o
  • 0xcaff
    0xcaff almost 9 years
    Is there a way to do this without repackaging the entire APK? Because apktool often fails to decompile then recompile with no modifications.
  • expert
    expert over 6 years
    I get Input file (app) was not found or was not readable. error. What does it mean ? If I omit last parameter I cannot build apk again.
  • Viktova
    Viktova over 5 years
    @expert it's because you're specifying a directory app, ommit "app" from the command. Apktool will automatically create a folder named base if the apk name was base.apk. on newer versions of apktool there's an option -o for output directory. enjoy =)
  • Tamilan C.Periyasamy
    Tamilan C.Periyasamy over 5 years
    Another one tool for AXMLPrinter. note this link google source (code.google.com/archive/p/android4me/downloads) java -jar ./AXMLPrinter2.jar ./debug.apk_FILES/AndroidManifest.xml