facebook / redex

A bytecode optimizer for Android apps
https://fbredex.com/
MIT License
6.03k stars 653 forks source link

redex-all crashed with exit code 1 #765

Open guobao90 opened 1 year ago

guobao90 commented 1 year ago

python3 redex.py -c default.config -o /Users/leo.zhang/Desktop/json/release/mcc_origin_out.apk /Users/leo.zhang/Desktop/json/release/mcc_origin.apk

error message: [ERROR ] Expecting value: line 9 column 45 (char 212) [WARNING ] Could not find an SDK jar: Could not find SDK path, searched Env, Buck Trace settings: TRACEFILE= SHOW_TIMESTAMPS= SHOW_TRACEMODULE= TRACE_METHOD_FILTER= TRACE_CLASS_FILE= TRACE_CLASS_NAME= error: No ProGuard keep rules provided. Redex optimizations will not preserve semantics without accurate keep rules. Traceback (most recent call last): File "/Users/leo.zhang/AndroidProject/redex/redex.py", line 1345, in with_temp_cleanup(lambda: run_redex(args), args.always_clean_up) File "/Users/leo.zhang/AndroidProject/redex/pyredex/utils.py", line 62, in with_temp_cleanup fn() File "/Users/leo.zhang/AndroidProject/redex/redex.py", line 1345, in with_temp_cleanup(lambda: run_redex(args), args.always_clean_up) File "/Users/leo.zhang/AndroidProject/redex/redex.py", line 1324, in run_redex run_redex_binary(state, exception_formatter, output_line_handler) File "/Users/leo.zhang/AndroidProject/redex/redex.py", line 397, in run_redex_binary run() File "/Users/leo.zhang/AndroidProject/redex/redex.py", line 390, in run raise RedexRunException(msg, returncode, abort_error, symbolized) main.RedexRunException: redex-all crashed with exit code 1! You can re-run it under gdb by running /var/folders/hx/78lkd49x14zcvmytj_6z8pkc3mx2f9/T/redex-gdb-crkljhsp.sh or under lldb by running /var/folders/hx/78lkd49x14zcvmytj_6z8pkc3mx2f9/T/redex-lldb-3eh35mq9.sh

please help check this

NTillmann commented 1 year ago

Somehow you seem to have a JSON parser that doesn't like the '#' comments in the default.config file. Can you edit it, and remove '#' and everything that follows in each line, and see if that fixes things for you?

leo9006 commented 1 year ago

Somehow you seem to have a JSON parser that doesn't like the '#' comments in the default.config file. Can you edit it, and remove '#' and everything that follows in each line, and see if that fixes things for you?

I remove the '#' in the comment, it doesn't work, it does not have this error

[ERROR ] Expecting value: line 9 column 45 (char 212)

others still have the same error message

NTillmann commented 1 year ago

I remove the '#' in the comment, it doesn't work [...]

Please try removing the entire comment, not just the leading '#'. The content needs to become legal JSON.

guobao90 commented 1 year ago

Yes, I remove all the comment

this is the detail config, but still have the same error message

{ "redex" : { "passes" : [ "ReBindRefsPass", "BridgeSynthInlinePass", "FinalInlinePassV2", "DelSuperPass", "SingleImplPass", "MethodInlinePass", "StaticReloPassV2", "RemoveEmptyClassesPass", "ShortenSrcStringsPass", "RegAllocPass" ] } }

guobao90 commented 1 year ago

I remove the '#' in the comment, it doesn't work [...]

Please try removing the entire comment, not just the leading '#'. The content needs to become legal JSON.

Yes, I remove all the comment

this is the detail config, but still have the same error message

{ "redex" : { "passes" : [ "ReBindRefsPass", "BridgeSynthInlinePass", "FinalInlinePassV2", "DelSuperPass", "SingleImplPass", "MethodInlinePass", "StaticReloPassV2", "RemoveEmptyClassesPass", "ShortenSrcStringsPass", "RegAllocPass" ] } }

is there any update?

Huxn commented 1 year ago

I remove the '#' in the comment, it doesn't work [...]

Please try removing the entire comment, not just the leading '#'. The content needs to become legal JSON.

Yes, I remove all the comment

this is the detail config, but still have the same error message

{ "redex" : { "passes" : [ "ReBindRefsPass", "BridgeSynthInlinePass", "FinalInlinePassV2", "DelSuperPass", "SingleImplPass", "MethodInlinePass", "StaticReloPassV2", "RemoveEmptyClassesPass", "ShortenSrcStringsPass", "RegAllocPass" ] } }

is there any update?

I have the same problem, based on the master code

fdh19979 commented 1 year ago

I have the same problem

/Users/user/redex/redex.py:24: DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13 from pipes import quote Trace settings: TRACEFILE= SHOW_TIMESTAMPS= SHOW_TRACEMODULE= TRACE_METHOD_FILTER= TRACE_CLASS_FILE= TRACE_CLASS_NAME= error: No ProGuard keep rules provided. Redex optimizations will not preserve semantics without accurate keep rules. Traceback (most recent call last): File "/Users/fudonghui/redex/redex.py", line 1345, in with_temp_cleanup(lambda: run_redex(args), args.always_clean_up) File "/Users/fudonghui/redex/pyredex/utils.py", line 62, in with_temp_cleanup fn() File "/Users/fudonghui/redex/redex.py", line 1345, in with_temp_cleanup(lambda: run_redex(args), args.always_clean_up) ^^^^^^^^^^^^^^^ File "/Users/fudonghui/redex/redex.py", line 1324, in run_redex run_redex_binary(state, exception_formatter, output_line_handler) File "/Users/fudonghui/redex/redex.py", line 397, in run_redex_binary run() File "/Users/fudonghui/redex/redex.py", line 390, in run raise RedexRunException(msg, returncode, abort_error, symbolized) RedexRunException: redex-all crashed with exit code 1! You can re-run it under gdb by running /var/folders/58/0n0pypp5257718fhxvy7frfh0000gn/T/redex-gdb-x2kc4qnp.sh or under lldb by running /var/folders/58/0n0pypp5257718fhxvy7frfh0000gn/T/redex-lldb-ux2zwbin.sh

NTillmann commented 1 year ago

So it seems like you could workaround the first error:

[ERROR ] Expecting value: line 9 column 45 (char 212)

But what remains is the second error:

error: No ProGuard keep rules provided. Redex optimizations will not preserve semantics without accurate keep rules.

You need to provide ProGuard keep rules.

lybill commented 1 year ago

So it seems like you could workaround the first error:

[ERROR ] Expecting value: line 9 column 45 (char 212)

But what remains is the second error:

error: No ProGuard keep rules provided. Redex optimizations will not preserve semantics without accurate keep rules.

You need to provide ProGuard keep rules.

How to solve this? I am also facing this problem

python redex.py --redex-binary build-cmake/redex-all.exe -o oouutt.apk C:\Users\hp\Desktop\app.apk

[WARNING ] No embedded files, please add manually! [ERROR ] expected str, bytes or os.PathLike object, not NoneType Trace settings: TRACEFILE= SHOW_TIMESTAMPS= SHOW_TRACEMODULE= TRACE_METHOD_FILTER= TRACE_CLASS_FILE= TRACE_CLASS_NAME= error: No ProGuard keep rules provided. Redex optimizations will not preserve semantics without accu rate keep rules. Traceback (most recent call last): File "D:\redex\redex\redex.py", line 1399, in with_temp_cleanup(lambda: run_redex(args), args.always_clean_up) File "D:/redex\redex/pyredex/utils.py", line 62, in with_temp_cleanup fn() File "D:\redex\redex\redex.py", line 1399, in with_temp_cleanup(lambda: run_redex(args), args.always_clean_up) File "D:\redex\redex\redex.py", line 1365, in run_redex run_redex_binary(state, exception_formatter, output_line_handler) File "D:\redex\redex\redex.py", line 398, in run_redex_binary run() File "D:\redex\redex\redex.py", line 377, in run raise RuntimeError(default_error_msg) RuntimeError: redex-all crashed with exit code 1!

NTillmann commented 1 year ago

https://fbredex.com/docs/proguard contains information on how to pass Proguard rules to Redex.