Encode/Decode AndroidManifest.xml inside APK
Asked Answered
B

2

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.

Boisvert answered 27/5, 2013 at 16:17 Comment(2)
Ask the developer for the original code or download the source. If you are reverse engineering someone else's code, then no help here.Manaus
@Manaus 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 ;)Boisvert
W
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.

Wynd answered 17/6, 2013 at 19:42 Comment(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 -oBarbabra
Is there a way to do this without repackaging the entire APK? Because apktool often fails to decompile then recompile with no modifications.Sharpfreeze
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.Karlotte
@Karlotte 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 =)Ballman
P
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

Plemmons answered 8/9, 2018 at 2:34 Comment(1)
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.xmlPlemmons

© 2022 - 2024 — McMap. All rights reserved.