Modifying the AndroidManifest.xml in Android APK File.

1. REQUIREMENTS :
Download and Install on your computer
1. JDK here
2. 7zip here or Winrar (recommended) here
3. Notepad++ here
4. Android SDK for patch 9.png until Zipalign the apk here
5. Apktool & baksmali/smali + Signer for all GB/ICS/JB ROM here
6. Apktool & baksmali/smali + Signer for all GB/ICS/JB ROM v2 here

 

apktool and following tools are the main tools.

zipalign.exe -> Android_SDK\tools
jarsigner.exe -> JDK_BIN Directory.

 

Main Steps:

[Decompile APK File]
D:\flexApk>java -jar apktool.jar d -f SECL_MobileANESample.apk decom

[Modify AndroidManifest.xml]
Do something you want to do in AndroidManifest.xml

[Recompile]
D:\flexApk>java -jar apktool.jar b -f decom

[Add Sign(Certification)]
C:\Program Files (x86)\Java\jdk1.6.0_45\bin>jarsigner.exe -verbose -keystore d:\seclnullnull D:\flexApk\SECL_MobileANESample_recomp.apk secl
(Verify the Sign, Optional) C:\Program Files (x86)\Java\jdk1.6.0_45\bin>jarsigner -verify d:\flexApk\SECL_MobileANESample_recomp.apk

[Zipalign it!]
D:\flexApk>zipalign -v 4 SECL_MobileANESample_recomp.apk SECL_MobileANESample_new.apk
(Verify the Sign, Optional) C:\Program Files (x86)\Java\jdk1.6.0_45\bin>jarsigner -verify d:\flexApk\SECL_MobileANESample_new.apk
[Bam!]

 

=============================================================================

Also made a ANT.Script to do theses stuff automatically.

 

<?xml version=”1.0″ encoding=”utf-8″?>

<project name=”SECL BAS_App Maker” default=”build.bas.app” basedir=”./release”>
    <property name=”TARGET_APK_NAME” value=”<APK_FileName>”/>
    <property name=”TARGET_APK” value=”${TARGET_APK_NAME}.apk”/>
    <property name=”DECOMP_DIR” value=”decomp”/>
    <property name=”SIGNED_APK_NAME” value=”${TARGET_APK_NAME}_sign”/>
    <property name=”SIGNED_APK” value=”${SIGNED_APK_NAME}.apk”/>
    <property name=”ZIPALIGNED_APK_NAME” value=”${TARGET_APK_NAME}_zipaligned”/>
    <property name=”ZIPALIGNED_APK” value=”${ZIPALIGNED_APK_NAME}.apk”/>
    <property name=”DISTRIBUTION_DIR” value=”dist”/>
    <property name=”KEY_STORE” value=”<YourKeyStoreName>”/>
    <property name=”KEY_STORE_PWD” value=”<YourKeyStorePWD>”/>
    <property name=”KEY_ALIAS” value=”<AliasName>”/>
   
       <target name=”decompile”>
        <echo message=”Decompile APK To decom Directory…”/>
        <java jar=”apktool.jar” fork=”true” failonerror=”true”>
          <arg value=”d”/>
          <arg value=”-f”/>
          <arg value=”${TARGET_APK}”/>
          <arg value=”${DECOMP_DIR}”/>
        </java>
    </target>
   
     <target name=”modify.andmanifest”>
        <echo message=”Modify the AndroidManifest.xml…”/>
        <replace
            file=”${DECOMP_DIR}/AndroidManifest.xml”
            token=”android.intent.category.LAUNCHER”
            value=”com.sds.mobiledesk.online.launcher”/>
    </target>
   
       <target name=”recompile”>
        <echo message=”Recompile Folder To APK File…”/>
        <java jar=”apktool.jar” fork=”true” failonerror=”true”>
          <arg value=”b”/>
          <arg value=”-f”/>
          <arg value=”${DECOMP_DIR}”/>
        </java>
    </target>
   
    <target name=”signapk”>
        <signjar
            sigalg=”MD5withRSA”
            digestalg=”SHA1″
            jar=”${DECOMP_DIR}/dist/${TARGET_APK}”
            signedjar=”${SIGNED_APK}”
            keystore=”${KEY_STORE}”
            storepass=”${KEY_STORE_PWD}”
            alias=”${KEY_ALIAS}”
            verbose=”true”
            force=”yes”/>
    </target>
   
    <target name=”zipAlign”>
        <exec executable=”./release/zipalign”>
          <arg value=”-v”/>
          <arg value=”4″/>
          <arg value=”${SIGNED_APK}”/>
          <arg value=”${ZIPALIGNED_APK}”/>
        </exec>
    </target>
   
    <target name=”move.rename”>
        <mkdir dir=”${DISTRIBUTION_DIR}”/>
        <move file=”${ZIPALIGNED_APK}” tofile=”${DISTRIBUTION_DIR}/${ZIPALIGNED_APK}”/>
        <rename src=”${DISTRIBUTION_DIR}/${ZIPALIGNED_APK}” dest=”${DISTRIBUTION_DIR}/${TARGET_APK}”/>
    </target>
   
    <target name=”delete.decomp.dir”>
           <delete includeemptydirs=”true”>
            <fileset dir=”.”>
                <include name=”${DECOMP_DIR}/**/*” />
                <include name=”${DECOMP_DIR}” />
            </fileset>
        </delete>
    </target>
   
    <target name=”delete.sign.apk”>
        <echo message=”Release 폴더 Sign Apk 파일 삭제..”/>
        <delete>
            <fileset dir=”.”>
                <include name=”*_sign.apk” />
            </fileset>
        </delete>
    </target>
   
    <target name=”build.bas.app”
        depends=”decompile, modify.andmanifest, recompile, signapk, zipAlign, move.rename, delete.decomp.dir, delete.sign.apk”>
    </target>
   
</project>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s