Can be used to change the value of android:value field for specific android:name.
This is very useful to package multiple APKs so that every APK has it's own channel name.
- Given one prebuilt apk (prebuilt.apk), run below commands:
java -jar axmleditor.jar prebuilt.apk UMENG_CHANNEL=baidu BD_APP_CHANNEL=baidu CHANNEL=baidu
It will parse the AndroidManifest.xml in prebuilt.apk, change the value of android:value to 'baidu', re-compile the xml, and put the compiled xml along with prebuilt.apk.
- Then user can use zip to add the compiled AndroidManifest.xml into apk. such as:
zip -d prebuilt.apk AndroidManifest.xml
zip prebuilt.apk AndroidManifest.xml
<meta-data
android:value="GooglePlay"
android:name="UMENG_CHANNEL"/>
<meta-data
android:value="GooglePlay"
android:name="BD_APP_CHANNEL"/>
<meta-data
android:value="GooglePlay"
android:name="CHANNEL"/>
<meta-data
android:value="Baidu"
android:name="UMENG_CHANNEL"/>
<meta-data
android:value="Baidu"
android:name="BD_APP_CHANNEL"/>
<meta-data
android:value="Baidu"
android:name="CHANNEL"/>
This project uses the xml parser of Google's ClassyShark project.
用于更改APK中AndroidManifest.xml中的属性值。非常适用于多渠道的打包,支持中文渠道名。
java -jar axmleditor.jar prebuilt.apk UMENG_CHANNEL=baidu BD_APP_CHANNEL=baidu CHANNEL=baidu
它会
-
解析prebuilt.apk中的AndroidManifest.xml
-
对android:name为UMENG_CHANNEL,BD_APP_CHANNEL,CHANNEL的属性,更改android:value的值为baidu
-
重新编译AndroidManifest.xml, 把编译后的AndroidManifest.xml放到prebuilt.apk同一目录下
aapt -d prebuilt.apk AndroidManifest.xml
aapt prebuilt.apk AndroidManifest.xml
<meta-data
android:value="GooglePlay"
android:name="UMENG_CHANNEL"/>
<meta-data
android:value="GooglePlay"
android:name="BD_APP_CHANNEL"/>
<meta-data
android:value="GooglePlay"
android:name="CHANNEL"/>
<meta-data
android:value="Baidu"
android:name="UMENG_CHANNEL"/>
<meta-data
android:value="Baidu"
android:name="BD_APP_CHANNEL"/>
<meta-data
android:value="Baidu"
android:name="CHANNEL"/>
- 使用了Google ClassyShark项目的xml解析部分。