Flutter debug Apk decompile to get source code

ⅰ亾dé卋堺 提交于 2020-01-24 03:11:45

问题


I have lost source code of my flutter application due to drive corruption but i have my debug.apk in my android phone . Can anyone please tell me how to decompile the Flutter apk to get source code. I have tried decompiling it using decompilers but it is not giving my source code as the flutter source code is in dart language .


回答1:


If your debug.apk is in debug mode, than you can use apktool in order to extract the components of the apk (I'm using the word extracting since apk is a zip file).

Flutter, in debug mode, keeps the source code (with comments!) in the file kernel_blob.bin. Thus, using the following command, should help you extract the code into a file:

strings /path/to/extracted/apk/assets/flutter_assets/kernel_blob.bin > extracted_code.dart

Please, pay attention - You'll need to clean 'extracted_code.dart', from irrelevant/garbage strings.

Try to search strings like "dart", "import", "void" and other key words in 'extracted_code.dart', it will help you find the code itself.

Here's an example from my Ubuntu:

If the apk is compiled in "release" mode, extracting the code will be much harder, since the code is compiled into isolate_snapshot_instr file, which is not a raw arm assembly, and is only deserialized using the Flutter engine in run-time. You can read more about it here



来源:https://stackoverflow.com/questions/53666487/flutter-debug-apk-decompile-to-get-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!