REAndroid / APKEditor

Powerful android apk editor - aapt/aapt2 independent
Apache License 2.0
647 stars 95 forks source link

Building apk failed after adding network_security_config #5

Closed pandamoon21 closed 1 year ago

pandamoon21 commented 1 year ago

Using xml type decoded apk

java -jar APKEditor.jar d -t xml -i apk.apk

I've put network_security_config.xml in nameofapp/res/xml as usual and added it in AndroidManifest.xml

<application
...
android:networkSecurityConfig="@xml/network_security_config"
...

This error showed when building the apk

java -jar APKEditor.jar b -i apk_decompile_xml -o apk_edited.apk
...
Local entry not found: type=xml, name=network_security_config
REAndroid commented 1 year ago

Whenever you add new resource, you should add/create new resource id at the end of types in public.xml Note: resource id = 0x xx(package id) xx(type id) xxxx(entry id)

CASE-1: When there is no type="xml" Take your last entry for if your last entry is <public id="0x7f130451" type="style" name="blah_blah"/> package id = 0x7f type id = 13 entry id = 0451

from above increment your type id by 1 which is 14 therefore your new resource id = 0x7f140000 then place this in your public xml <public id="0x7f140000" type="xml" name="network_security_config"/>

CASE-2: When there is type="xml"

Take your last entry from xml types if your last entry is <public id="0x7f160008" type="xml" name="blah_blah"/> package id = 0x7f type id = 16 entry id = 0008

from above increment your entry id by 1 which is 0009 therefore your new resource id = 0x7f160009 then place this in your public xml <public id="0x7f160009" type="xml" name="network_security_config"/>