25

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.

2
  • 1
    Ask the developer for the original code or download the source. If you are reverse engineering someone else's code, then no help here.
    – Simon
    May 27, 2013 at 16:48
  • 1
    @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 ;) Jul 13, 2015 at 8:38

2 Answers 2

36

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.

4
  • 4
    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 Apr 21, 2015 at 15:41
  • 1
    Is there a way to do this without repackaging the entire APK? Because apktool often fails to decompile then recompile with no modifications.
    – 0xcaff
    Jul 15, 2015 at 16:35
  • 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.
    – expert
    Jan 6, 2018 at 12:55
  • @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 =)
    – Viktova
    Aug 23, 2018 at 8:38
4
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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.