REAndroid / APKEditor

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

Building back from decompilation to apk fails #20

Closed sekaiacg closed 1 year ago

sekaiacg commented 1 year ago

1.APKEditor version: 1.2.0 2.apk file: Settings.apk

3.run: java -jar APKEditor.jar d -i Settings.apk

00.000 I: [DECOMPILE] Decompiling ...
   Input: Settings.apk
 Output: Settings_decompile_null
 Type: json
 Split: false
 ---------------------------- 
00.020 I: [DECOMPILE] Loading ...
00.579 I: [DECOMPILE] Initializing android framework ...
00.579 I: [DECOMPILE] Loading android framework for version: 33
00.614 I: [DECOMPILE] Initialized framework: android-33
00.614 I: [DECOMPILE] Decompiling to JSON ...
00.659 I: [DECOMPILE] [SANITIZE]: Sanitizing paths ...
00.663 [DECOMPILE] [SANITIZE]: REN: 'META-INF/external__kotlinx.coroutines__android_common__kotlinx_cor                                                                                                       00.663 [DECOMPILE] [SANITIZE]: REN: 'META-INF/packages__apps__MiuiSettingsLib__android_common__MiuiSettingsLib.kotlin_module' -> 'META-INF/alias_45341996'
00.667 I: [DECOMPILE] [SANITIZE]: DONE = 10572
03.648 I: [DECOMPILE] Dumping signatures ...
03.648 I: [DECOMPILE] Saved to: Settings_decompile_null
03.648 I: [DECOMPILE] Done

do not make any changes.

4.run: java -jar APKEditor.jar b -i Settings_decompile_null

00.000 I: [BUILD] Building ...
   Input: Settings_decompile_null/base
 Output: Settings_decompile_null_out.apk
 ---------------------------- 
00.019 I: [BUILD] Scanning JSON directory ...
00.103 I: [BUILD] Restoring file path ...
00.104 I: [BUILD] Building resources table: resources.arsc

Unexpected error:
java.io.IOException: resources.arsc: JSONObject["style"] not found.
java.lang.IllegalArgumentException: java.io.IOException: resources.arsc: JSONObject["style"] not found.
    at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:566)
    at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:573)
    at com.reandroid.apk.ApkModule.listResFiles(ApkModule.java:398)
    at com.reandroid.apk.ApkModule.listResFiles(ApkModule.java:394)
    at com.reandroid.apk.PathMap.restore(PathMap.java:37)
    at com.reandroid.apk.ApkJsonEncoder.restorePathMap(ApkJsonEncoder.java:82)
    at com.reandroid.apk.ApkJsonEncoder.scanDirectory(ApkJsonEncoder.java:48)
    at com.reandroid.apkeditor.compile.Builder.buildJson(Builder.java:69)
    at com.reandroid.apkeditor.compile.Builder.run(Builder.java:49)
    at com.reandroid.apkeditor.compile.Builder.execute(Builder.java:159)
    at com.reandroid.apkeditor.Main.execute(Main.java:65)
    at com.reandroid.apkeditor.Main.main(Main.java:38)
Caused by: java.io.IOException: resources.arsc: JSONObject["style"] not found.
    at com.reandroid.apk.SingleJsonTableInputSource.getTableBlock(SingleJsonTableInputSource.java:68)
    at com.reandroid.apk.ApkModule.loadTableBlock(ApkModule.java:652)
    at com.reandroid.apk.ApkModule.getTableBlock(ApkModule.java:560)
    ... 11 more
REAndroid commented 1 year ago

This issue is fixed on ARSCLib, you can build your own jar or download updated release APKEditor-1.2.0.jar

Tip: Decompile/Build in JSON format is highly accurate even if obfuscated, however if your apk's resources are not obfuscated you can do the same in XML format by adding option -t xml to decode args like: java -jar APKEditor.jar d -t xml -i your_file.apk

sekaiacg commented 1 year ago

Thanks! no more json errors, this problem has been perfectly fixed. I tried -t xml but it causes incorrect ui layout. Using other tools to view the compiled resources.arsc file prompts an error. Maybe some apk in this rom is obfuscated, everything works fine with json.

UI problem after using xml: QQ_Image_1683026700983

error info: QQ_Image_1683026293247

TAG: 2.13.4(23040183)
ROOT: true
ABI: arm64-v8a
MODEL: 22021211RC
SDK: 33
RELEASE: 13
---StackTrace---
java.lang.RuntimeException:  [com.android](http://com.android/) .settings/attr/actionBarSplitMaxPercentageHeight 192 65472
    at l.ۧ۟ۛ.ۨ(L63Q:152)
    at l.۠۟ۛ.ۨ(05W2:138)
    at l.ۖ۟ۛ.ۨ(15Y4:149)
    at l.۟۟ۛ.ۨ(D622:174)
    at l.ۢ۟ۛ.ۨ(W54R:118)
    at l.ۛ۟ۛ.ۨ(S4NY:62)
    at l.ۗۡۧ.ۨ(21FW:1008)
    at l.ۗۡۧ.ۖ(21FW:835)
    at l.ۗ۟ۧ.ۥ(81KA:569)
    at l.ۨۙۨۨ.ۨ(U4WR:101)
    at l.ۤۤ۟.run(DATL:0)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( [ThreadPoolExecutor.java:1137](http://threadpoolexecutor.java:1137/) )
    at java.util.concurrent.ThreadPoolExecutor$Worker.run( [ThreadPoolExecutor.java:637](http://threadpoolexecutor.java:637/) )
    at  [java.lang.Thread.run](http://java.lang.thread.run/) ( [Thread.java:1012](http://thread.java:1012/) )

The original version of the apk in question is the one compiled with xml: Settings_use_xml.apk

sekaiacg commented 1 year ago

thanks for your work.

REAndroid commented 1 year ago

I thought I fixed this issue a while ago. Now I fixed the issue and updated all along with the release APKEditor-1.2.0.jar Your apk should work fine with this

sekaiacg commented 1 year ago

I conducted a test, resources.arsc is no longer wrong. but the UI layout is not correct, is there a problem with xml parsing? I used the recompiled apk (xml) to decompile to json format again, and found that it could not match the original apk decompiled json file in some places.

The left side uses the xml format and decompiles it into json again.(Settings_decompile_xml_out_decompile_json) Settinhs_test.zip example: base/res-json/res/drawable-sw600dp-v13/core_scan_gesture_broadside.xml.json 1 2

REAndroid commented 1 year ago

The error was DIMESION value encode/decode. On this case raw value -47615 supposed to be decoded as -186.0dp. Now this issue seems to be fixed and check the latest update.

You are pointing out good issues, hope you will keep doing same. Thank You !

sekaiacg commented 1 year ago

The error was DIMESION value encode/decode. On this case raw value -47615 supposed to be decoded as -186.0dp. Now this issue seems to be fixed and check the latest update.

You are pointing out good issues, hope you will keep doing same. Thank You !

After testing, the UI layout is normal. Another question: value_type: INT_COLOR_ARGB8(xml) and INT_COLOR_RGB8(json) represent the same type? The results of xml and json are inconsistent.

sekaiacg commented 1 year ago

Question 1: I found that some resource hooks in the apk compiled back using xml are invalid (third-party themes can change the text options in the settings, but some do not take effect). QQ_Image_1683124917618

If it does not take effect, the default content will be used:
        "entry_name": "personalize_title",
        "value": {
         "value_type": "STRING",
         "data": "壁纸与个性化"
        },

The strange thing is that the problem disappears after decompiling the problematic apk using json and then compiling it back to apk. Settings_decompile_xml_out.apk : not take effect Settings_decompile_xml_out_decompile_json_out.apk : take effect apk file: Settings_test2.zip

I think compiling back to apk with xml might cause some unknown issues.


Question 2: When decompiling AndroidManifest.xml, extra spaces and characters appear: ' 3

REAndroid commented 1 year ago

Question 1: I found that some resource hooks in the apk compiled back using xml are invalid (third-party themes can change the text options in the settings, but some do not take effect).

On your apk, the value was decoded as <string name="personalize_title">Wallpaper &amp;amp; personalization</string> for value of Wallpaper & personalization . But I am not sure it will fix this issue, I will get back after making some investigation, in the meantime check the latest update

REAndroid commented 1 year ago

Another question: value_type: INT_COLOR_ARGB8(xml) and INT_COLOR_RGB8(json) represent the same type? The results of xml and json are inconsistent.

This was wrong, now fixed

Question 2: When decompiling AndroidManifest.xml, extra spaces and characters appear: '

This is correct parsing, those additional characters are existed on original bin xml

sekaiacg commented 1 year ago

Another question: value_type: INT_COLOR_ARGB8(xml) and INT_COLOR_RGB8(json) represent the same type? The results of xml and json are inconsistent.

This was wrong, now fixed

Question 2: When decompiling AndroidManifest.xml, extra spaces and characters appear: '

This is correct parsing, those additional characters are existed on original bin xml

I use the latest updated version for testing: 1.INT_COLOR_RGB8 fixed. 2.Question 1 still exists. 3.Because there are special characters in the original AndroidManifest.xml, it can also be expected.

REAndroid commented 1 year ago

2.Question 1 still exists. 3.Because there are special characters in the original AndroidManifest.xml, it can also be expected.

The developer of this apk put those characters AndroidManifest.xml for some reason or mistake. Not the problem of the parser. Check AndroidManifest.xml.json

      {
       "node_type": "text",
       "text": " ' "
      }
sekaiacg commented 1 year ago

ok, I know, thank you.

sekaiacg commented 1 year ago

Hi, the problem caused by using xml was also found in other apk.

In the following apk, after compiling back with xml, the options in the red box are not displayed. apk file: Home_test.zip IMG_20230504_201701

At the same time, some devices may crash after installing the apk.

05-04 20:28:37.629 15524 15524 E AndroidRuntime: FATAL EXCEPTION: main
05-04 20:28:37.629 15524 15524 E AndroidRuntime: Process: com.miui.home, PID: 15524
05-04 20:28:37.629 15524 15524 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at miuix.preference.DropDownPreference$1$1.run(DropDownPreference.java:67)
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:942)
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:210)
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:299)
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8116)
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559)
05-04 20:28:37.629 15524 15524 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

There is no problem parsing with json, all works fine.

REAndroid commented 1 year ago

Odd apk , arrays supposed to have attributes 0x01000000, 0x01000001, 0x01000002 ... but this apk has all name values 0. My guess is that it was modified by non aapt tool.

Anyways it's fixed now check the latest updates

sekaiacg commented 1 year ago

Odd apk , arrays supposed to have attributes 0x01000000, 0x01000001, 0x01000002 ... but this apk has all name values 0. My guess is that it was modified by non aapt tool.

Anyways it's fixed now check the latest updates

I used the latest updated version to test, and the problem still persists. Is there a better way to find the problem? Now the problem I found is no longer easy to locate by simple file comparison...

In addition, I may have found the cause of the problem by using grep. Using json, its value_type is string The one on the right is parsed directly using json Home_decompile_xml_out_decompile_json------Home_decompile_json resources.arsc.json: 4

5

I got some wrong places after I used regex to exclude "line": There may be more than one file with the same type of problem. navigation_bar_type_settings.xml.json: 6

miui_home_dialog_anim_pop_in_center.xml.json: 7

material_ic_clear_black_24dp.xml.json: 8

material_ic_clear_black_24dp.xml.json: 9

smallwindow_icon.xml.json: 10

notification_action_background.xml.json: 11

miuix_sbl_tracking_progress_ellipse_bg.xml.json: 12

I thought of a way: create an apk with all value_type, using json and xml respectively (again using json decompilation). Compare their differences separately, so the workload is much less.

Why is json parsing correct and xml wrong? Are their implementations different?

REAndroid commented 1 year ago

Why is json parsing correct and xml wrong? Are their implementations different?

Good question, Consider dex(dalvik) decompiling we can decompile/compile to smali or java but most of the times java gets error

Decompiling to XML is not 1:1 it is based on guess and assumptions e.g. you have a value 1234 there is no direct way to tell for XML this is STRING or INTEGER or FLOAT but for JSON you simply specify it with value_type:"xxxx". XML by itself has its own limitation/weakness.

This is the reason why i came up with idea of JSON format as an agent between low level byte code and humans to modify binary resources with 100% accuracy. If you check commits history I added XML support lately because most developers are used to XML and got confused with the new JSON.

I always recommend to use JSON format (if you are good at it) it is guaranteed to be 100% accurate.

Anyways we will keep improving XML conversion but there is no logical way to reach 100% error free.

REAndroid commented 1 year ago

smallwindow_icon.xml.json:

Fixed with this commit I will update releases latter after fixing other issues

sekaiacg commented 1 year ago

Thanks for your answer, I understand the difference between xml and json. I will test it after fixing the problem.

REAndroid commented 1 year ago

Fixed major issues and release updated, you can test it now

sekaiacg commented 1 year ago

Fixed major issues and release updated, you can test it now

I tested with the latest update:

  1. The STRING type of resources.arsc.json has been fixed
  2. The data of DIMENSION and INT_COLOR_RGB4 has been fixed Now the apk basically works fine.
sekaiacg commented 1 year ago

At the same time, compared with the previous APK, it is found that some xml has special characters, but after parsing the xml for the second time, there are more newlines and spaces after the special characters, which is different from the previous format. Probably similar to the json in the previous question. apk file: Settings_test3.zip The right is parsed directly through XML. Settings_decompile_xml_out_decompile_xml---------------------------------Settings_decompile_xml res/drawable/color_bar_progress.xml: 1

Through simple comparison, it is found that the content in some xml is different or missing: res/values/colors.xml: 2

res/values/dimens.xml: 3

res/values/strings.xml: 4

The right side is parsed directly using json. Settings_decompile_xml_out_decompile_json----------------------------------------Settings_decompile_json res/layout/accessibility_edit_shortcut_magnification_pad.xml.json: value_type inconsistent 5

REAndroid commented 1 year ago

Seems to be fixed now, check updates

sekaiacg commented 1 year ago
  • Color
  • Style string

Seems to be fixed now, check updates

1.Color has been fixed.

  1. There is still a problem with the string, the content lacks spaces, I am very sorry, I ignored it yesterday. res/values/strings.xml: 6
  2. Other problems are still not fixed(value_type...).
sekaiacg commented 1 year ago

Question 1: I found that some resource hooks in the apk compiled back using xml are invalid (third-party themes can change the text options in the settings, but some do not take effect). QQ_Image_1683124917618

If it does not take effect, the default content will be used:
        "entry_name": "personalize_title",
        "value": {
         "value_type": "STRING",
         "data": "壁纸与个性化"
        },

The strange thing is that the problem disappears after decompiling the problematic apk using json and then compiling it back to apk. Settings_decompile_xml_out.apk : not take effect Settings_decompile_xml_out_decompile_json_out.apk : take effect apk file: Settings_test2.zip

I think compiling back to apk with xml might cause some unknown issues.

Question 2: When decompiling AndroidManifest.xml, extra spaces and characters appear: ' 3


At the same time, if the APK is processed smoothly according to the following three items, the results obtained will be inconsistent.

apk→xml→apk: not take effect apk→xml→apk→json→apk: take effect apk→json→apk: take effect

Add 2 content that has no effect:

        "entry_name": "display_settings",
        "value": {
         "value_type": "STRING",
         "data": "Display"
        },
...
        "entry_name": "sound_haptic_settings",
        "value": {
         "value_type": "STRING",
         "data": "Sound & touch"
        },

I'm using the latest updated version and haven't modified anything, so I don't understand what the difference is. This is a very miraculous phenomenon. Because the problem can be solved by recompiling the APK that has no effect using json decompilation again.

REAndroid commented 1 year ago

I will fix this and other issues and get back to you

REAndroid commented 1 year ago

Question 1: I found that some resource hooks in the apk compiled back using xml are invalid (third-party themes can change the text options in the settings, but some do not take effect).

I can't figure out where exactly this problem is. I compared (using custom program byte level) files built with json & xml, most differences are irrelevant except config size 64(xml) & 48(json) and I doubt this fixes your issue.

I updated releases, you can test now and it will be better if you can get some stacktraces/logs

sekaiacg commented 1 year ago

I tested with the latest updated version. The latest version causes APK language resource exception. It is set to Simplified Chinese, but it is actually Traditional Chinese, and the language cannot be switched. Sorry, I have no way to continue testing... The results after 2 decompilations using xml cannot be compared... Settings_decompile_xml_out_decompile_xml--------------------------------Settings_decompile_xml 01

I think the new version may have broken some resource. Using json works fine.

REAndroid commented 1 year ago

Ohh I made silly mistake here. Check the latest update

sekaiacg commented 1 year ago

Ohh I made silly mistake here. Check the latest update

Tested with the latest version, Question 1 is not resolved. i didn't find the log...

REAndroid commented 1 year ago

Can you send me some of "third-party" apps ?

sekaiacg commented 1 year ago

Can you send me some of "third-party" apps ?

The theme will not generate effects on third-party apps.

This is the theme supported by MIUI ROM. It requires the built-in ThemeManager.apk to apply. It can modify option text in settings (Settings.apk). Using -t xml to compile APK (Settings.apk) will cause the text of some options to fail to take effect.

Like I said above, just compiling again with json will solve the problem. This shows that xml and json are correct when parsing the content of the ARSC file. I'm guessing the problem might be remaking the ARSC file.

There are no relevant errors in the logs. I don't know how to go about debugging it.

sekaiacg commented 1 year ago

This is the value_xml(com.android.settings) file of Settings

<?xml version='1.1' encoding='utf-8' standalone='yes' ?>
<MIUI_Theme_Values>
<string name="miui_more_special_feature">探索功能</string>
<string name="data_usage_summary_title">流量情况</string>
<string name="ai_button_title">智能按键</string>
<string name="emergency_sos_title">紧急求助</string>
<string name="my_device">我的设备</string>
<string name="about_settings">关于手机</string>
<string name="header_category_wireless_networks">网络连接</string>
<string name="sim_management_title">双卡网络</string>
<string name="wifi_settings_title">无线网络</string>
<string name="bluetooth_settings_title">蓝牙连接</string>
<string name="wifi_tether_settings_title">个人热点</string>
<string name="app_name_na">网络助手</string>
<string name="vpn_settings_title">代理设置</string>
<string name="radio_controls_title">更多方式</string>
<string name="display_settings">显示设置</string>
<string name="sound_vibrate_settings">声音振动</string>
<string name="lock_settings">锁屏密码</string>
<string name="lock_settings_with_fingerprint">密码指纹</string>
<string name="status_bar_settings">通知设置</string>
<string name="infinity_display_title">全屏手势</string>
<string name="second_space">手机分身</string>
<string name="do_not_disturb_mode">勿扰模式</string>
<string name="power_usage_summary_title">电量性能</string>
<string name="pref_edge_handgrip">边缘触控</string>
<string name="game_mode_settings">游戏模式</string>
<string name="miui_lab_settings">实验功能</string>
<string name="oldman_mode_entry_name">极简桌面</string>
<string name="other_advanced_settings">更多设置</string>
<string name="xiaomi_account">小米帐号</string>
<string name="sync_settings">自动同步</string>
<string name="system_app_settings">系统应用</string>
<string name="applications_settings">更多应用</string>
<string name="xspace">应用双开</string>
<string name="permission_manager">授权管理</string>
<string name="application_lock_name">应用守护</string>
<string name="usage_state_app_timer">屏幕时间</string>
<string name="launcher_title">桌面管理</string>
<string name="account_list">其他账号</string>
<string name="header_category_accounts">账号管理</string>
<string name="home_title">桌面管理</string>
<string name="aod_and_lock_screen_settings_title">息屏锁屏</string>
<string name="password_security_settings_title">密码安全</string>
<string name="security_settings_title">密码管理</string>
<string name="lock_screen_settings_title">锁屏管理</string>
<string name="security_keyguard_category_name">锁屏管理</string>
<string name="password_and_security">密码安全</string>
<string name="connection_and_sharing">连接共享</string>
<string name="notification_control_center">通知控制</string>
<string name="feedback_settings">服务反馈</string>
<string name="power_usage_summary_title_new">电量性能</string>
<string name="wallpaper_settings_title">桌面壁纸</string>
<string name="personalize_title">桌面壁纸</string>
<string name="wallet_header_title">钱包支付</string>
<string name="card_holder_header_title">钱包支付</string>
<string name="sound_haptic_settings">声音触感</string>
<string name="security_center_title">安全管理</string>
<string name="fingerprint_face_password_unlock">密码管理</string>

<string-array name="handy_mode_size_text_entries">
<item>4.5 英寸</item>
<item>4.0 英寸</item>
<item>3.5 英寸</item>
<item>2.5 英寸</item>
<item>2.0 英寸</item>
<item>1.5 英寸</item>
<item>1.0 英寸</item>
<item>0.5 英寸</item>
</string-array>
......
</MIUI_Theme_Values>

some of them don't work

<string name="personalize_title">桌面壁纸</string>
<string name="display_settings">显示设置</string>
<string name="sound_haptic_settings">声音触感</string>
...

It's possible that it has something to do with the frame. json can guarantee 100% correctness. If no progress is made, this issue can be closed first.

Thanks for your work.

REAndroid commented 1 year ago

No point closing this issue without finding out the exact problem. I am making new separate program to compare resources in detail. I will get back to you when it is done

REAndroid commented 1 year ago

Here I made a massive change you can test it with APKEditor-1.2.0-UPDATE-01.jar

sekaiacg commented 1 year ago

Here I made a massive change you can test it with APKEditor-1.2.0-UPDATE-01.jar

  • The only problem I found was it doesn't remove unused strings from pool

This version does not solve the problem. This question is very peculiar....

REAndroid commented 1 year ago

Check APKEditor-1.2.0-UPDATE-02.jar

sekaiacg commented 1 year ago

Check APKEditor-1.2.0-UPDATE-02.jar

Your link is APKEditor-1.2.0-UPDATE-01.jar But I downloaded it again: https://github.com/REAndroid/APKEditor/releases/download/V1.2.0/APKEditor-1.2.0-UPDATE-02.jar

Sorry, the problem is not resolved... json works fine.

I used other tools to modify the contents of the ARSC file individually(Then it took effect): 02

Settings_decompile_xml_out.apk: not take effect Settings_decompile_xml_out_other_tool_mod.apk: take effect

Can you use it to figure out why?

APK file: Settings_test6.zip

REAndroid commented 1 year ago

Settings_decompile_xml_out.apk: not take effect Settings_decompile_xml_out_other_tool_mod.apk: take effect

This files are wrongly edited by your tool and the resource ids are distorted.

Since your apk is also framework, resources must be publicized to be accessible by other apps.
Here is an update with other major issues fixed: APKEditor-1.2.0-UPDATE-03.jar

sekaiacg commented 1 year ago

Settings_decompile_xml_out.apk: not take effect Settings_decompile_xml_out_other_tool_mod.apk: take effect

This files are wrongly edited by your tool and the resource ids are distorted.

I don't know what's wrong with this. But this tool recompiles the ARSC file, just modifying it with it will solve the problem. This has the same effect as recompiling with json. After these tests, it is also proved that the ARSC file compiled by json (APKEditor) is correct.

Since your apk is also framework, resources must be publicized to be accessible by other apps. Here is an update with other major issues fixed: APKEditor-1.2.0-UPDATE-03.jar

After testing, this version does not solve the problem. Below is the original APK/JSON and XML compiled effect. There should be some errors in the ARSC file compiled by xml. 03 04

REAndroid commented 1 year ago
  1. original > decompile to xml > compile Settings_decompile_xml_out.apk
  2. apk from 1 > decompile to json > compile Settings_decompile_xml_out_decompile_json_out.apk
sekaiacg commented 1 year ago

I changed the text to English. custom theme value:

<?xml version='1.1' encoding='utf-8' standalone='yes' ?>
<MIUI_Theme_Values>
......
<string name="personalize_title">Wallpaper &amp; personalization test1</string>
<string name="display_settings">Display test2</string>
......
</MIUI_Theme_Values>
original apk/json(APK Default Text) original apk/json(custom theme: Correct-Text) xml(custom theme: Wrong-Text)
Wallpaper & personalization Wallpaper & personalization test1 Wallpaper & personalization
Display Display test2 Display

01 02 03

REAndroid commented 1 year ago

I think I misunderstood you this whole time, when you mean by "apply-theme" do you mean edit the apk with other tool ?

sekaiacg commented 1 year ago
  1. Theme is a feature in ROM which can change the text without modifying the system APK.
  2. Settings.apk is the system APK.
  3. Settings.apk only use APKEditor to decompile and then compile back. No resources were modified. Use -t xml to decompile and then compile it back, there will be some text that cannot be covered by the theme. There will be no problem with json.

This reply explains the phenomenon of the problem in detail: https://github.com/REAndroid/APKEditor/issues/20#issuecomment-1555944377

"apply-theme" does not mean modifying the APK. Theme Manager:

04

REAndroid commented 1 year ago

I found issue on duplicate resource names, check this update APKEditor-1.2.0-UPDATE-04.jar

sekaiacg commented 1 year ago

I found issue on duplicate resource names, check this update APKEditor-1.2.0-UPDATE-04.jar

Great, this version fixes the problem.

sekaiacg commented 1 year ago

Thanks for your work.

REAndroid commented 1 year ago

Good ! We have solved a lot of issue on the way. I will update repos with proper release and I will credit you for your contribution. Thank you!

REAndroid commented 1 year ago

Check the latest release : V1.2.1

sekaiacg commented 1 year ago

Check the latest release : V1.2.1

After testing, both xml and json are working fine.