[Tool] (v5.0) Fully automated tool for create deodex from ART (Nougat support)

svadev

Senior Member
Dec 13, 2014
133
481
93
This Toolkit for creating deodex firmware from android runtime (ART).

Changelog (v5.5) from 21/04/2017:


  1. SamsungInCallUI.apk deodexing without errors. For it i developed and implemented the method of heavy deodexing for SamsungInCallUI.apk
  2. You must specify the path to the full stock /system directory to create script commands for all symlinks, not just for libraries.
  3. Full support Android Lollipop/Marsmallow/Nougat. Automatic detection android version (Lollipop/Marsmallow/Nougat)
  4. More optimizations
  5. Detected and fixed small errors
New version v5.5 here






Changelog (v5.0) from 08/12/2016:

  1. Support Android Lollipop/Marsmallow/Nougat
  2. Automatic detection android version (Lollipop/Marsmallow/Nougat)
  3. More optimizations
  4. Fixed errors
Version v5.0 here




SVADeodexerForArt.jpg

New version v4.1 here

Changelog (v4.1) from 09/03/2016:
Fixed a bug in the processing of non-standard sequence file build.prop

Changelog (v4.0) from 23/11/2015:


1. Added full support for Android M
2. More optimizations


Changelog (v3.5) from 20/07/2015:

1. Added full support for processor architectures:


  • arm
  • arm64
  • x86
  • x64
  • mips
  • mips64
2. More optimizations


Archive changelog:

Changelog (v3.2) from 02/07/2015:

1. Fixed copy folders without .apk, like mcRegistry to result folder (app, priv-app)
2. New oat2dex.jar v0.83 with full support Android 5.1.1 (thanks @_riddle) and with last smali/baksmali

Changelog (v3.1) from 26/04/2015:

1. For 64-bit stock only added checkbox "Copy to result, not deodexed arm folders, if any, in addition to deodexed arm64 folders".
If user checked it, then arm folders for framework and apks, that have arm and arm64 will be copied to result.
2.
mcRegistry folder and file such FFFFFFFF000000000000000000000001.drbin now copied to result
3. Checkbox "copy only real libs" - deleted

Changelog (v3.0) from 25/04/2015:

1. Added full support arm64
2.
The program has become even more intelligent and gives a more correct result(see example of log)

Changelog (v2.6):

1. Added support arm64
2.
New oat2dex.jar (v07) with smali/baksmali v2.0.5


Changelog
(v2.5):


1. You may drag and drop /system folder from Windows Explorer to SVADeodexerForArt.exe form.
2. If you double click on "select path to stock /system directory" combobox, then tool will be search all /system folders of stock Lollipop firmwares on computer (use carefully - it may take 4-5 minutes)
3. Fixed small errors (for example: tool now will see links to libs with "systemfile" attr).

Improved performance, the program has become more intelligent and gives a more correct result.
And in the log contains information that will be useful for developers.


Example of log
SVADeodexerForArt.exe

Code:
64-bit Deodexer for Android Runtime  (Version 3.5 от 20/07/2015)  © Valery Studenikin, 2015

Path to stock /system directory: F:\TEMP\S6 Duos\G9200\firmware\G9200ZCU1AOFE_G9200CHC1AOFE_CHC\system
Android 5.0.2: SM-G9200, LRX22G.G9200ZCU1AOFE, changelist 4635752, Sun Jun 28 20:45:21 KST 2015
Processor architecture: \arm64\
Files deodexed succesfully: 365,   with errors: 0.   CPU time: 00:05:57 (357,134 sec.)



The necessary links for applications libraries:

    symlink("/system/lib/libaed.so", "/system/app/AdvSoundDetector2015/lib/arm/libaed.so");
    symlink("/system/lib/libfdb.so", "/system/app/AdvSoundDetector2015/lib/arm/libfdb.so");
    symlink("/system/lib/libSamsungBCPP.so", "/system/app/AdvSoundDetector2015/lib/arm/libSamsungBCPP.so");
    symlink("/system/lib/libasf_fileshare.so", "/system/app/AllshareFileShare/lib/arm/libasf_fileshare.so");
    symlink("/system/lib/libasf_fileshareserver.so", "/system/app/AllshareFileShareServer/lib/arm/libasf_fileshareserver.so");
    symlink("/system/lib/libasf_mediashare.so", "/system/app/AllshareMediaShare/lib/arm/libasf_mediashare.so");
    symlink("/system/lib/libbluetooth_jni.so", "/system/app/Bluetooth/lib/arm/libbluetooth_jni.so");
    symlink("/system/lib64/libnfc_nci_jni.so", "/system/app/NfcNci/lib/arm64/libnfc_nci_jni.so");
    symlink("/system/lib64/libjni_pacprocessor.so", "/system/app/PacProcessor/lib/arm64/libjni_pacprocessor.so");
    symlink("/system/lib/libmorpho_panorama_wa_for_viewer.so", "/system/app/Panorama360Viewer_Zero/lib/arm/libmorpho_panorama_wa_for_viewer.so");
    symlink("/system/lib/libmorpho_sensor_fusion_for_viewer.so", "/system/app/Panorama360Viewer_Zero/lib/arm/libmorpho_sensor_fusion_for_viewer.so");
    symlink("/system/lib/libcommonpawrapper.so", "/system/app/RootPA/lib/arm/libcommonpawrapper.so");
    symlink("/system/lib/libnmsp_sk_speex.so", "/system/app/SamsungChineseIMEv9/lib/arm/libnmsp_sk_speex.so");
    symlink("/system/lib/libapa_jni.so", "/system/app/SapaMonitor/lib/arm/libapa_jni.so");
    symlink("/system/lib64/libgkdp_sv_engine.so", "/system/app/SCService/lib/arm64/libgkdp_sv_engine.so");
    symlink("/system/lib64/libscservice_jni.so", "/system/app/SCService/lib/arm64/libscservice_jni.so");
    symlink("/system/lib/libDioDict3EngineNativeFrame.so", "/system/app/SecDict2Zero/lib/arm/libDioDict3EngineNativeFrame.so");
    symlink("/system/lib/libdioiculemma.so", "/system/app/SecDict2Zero/lib/arm/libdioiculemma.so");
    symlink("/system/lib/libjma.so", "/system/app/SecDict2Zero/lib/arm/libjma.so");
    symlink("/system/lib/libnltk.so", "/system/app/SecDict2Zero/lib/arm/libnltk.so");
    symlink("/system/lib/libstlport_shared.so", "/system/app/SecDict2Zero/lib/arm/libstlport_shared.so");
    symlink("/system/lib64/libprintspooler_jni.so", "/system/app/SPrintSpooler/lib/arm64/libprintspooler_jni.so");
    symlink("/system/lib/libTui.so", "/system/app/TuiService/lib/arm/libTui.so");
    symlink("/system/lib64/libdefcontainer_jni.so", "/system/priv-app/DefaultContainerService/lib/arm64/libdefcontainer_jni.so");
    symlink("/system/lib64/libPlatformStrings.so", "/system/priv-app/HealthService/lib/arm64/libPlatformStrings.so");
    symlink("/system/lib64/libSensorNativeProtocol.so", "/system/priv-app/HealthService/lib/arm64/libSensorNativeProtocol.so");
    symlink("/system/lib/libsecipx.so", "/system/priv-app/OutOfFocusViewer_WQHD_K/lib/arm/libsecipx.so");
    symlink("/system/lib/libSisoJpegCodec.so", "/system/priv-app/OutOfFocusViewer_WQHD_K/lib/arm/libSisoJpegCodec.so");
    symlink("/system/lib/libSRIB_FocusShot.so", "/system/priv-app/OutOfFocusViewer_WQHD_K/lib/arm/libSRIB_FocusShot.so");
    symlink("/system/lib64/libPedometer.so", "/system/priv-app/SHealth4/lib/arm64/libPedometer.so");
    symlink("/system/lib64/libPlatformStrings.so", "/system/priv-app/SHealth4/lib/arm64/libPlatformStrings.so");
    symlink("/system/lib64/libsaiv.so", "/system/priv-app/SHealth4/lib/arm64/libsaiv.so");
    symlink("/system/lib64/libSensorNativeProtocol.so", "/system/priv-app/SHealth4/lib/arm64/libSensorNativeProtocol.so");
    symlink("/system/lib64/lib_stressanalyzer_v03_jni.so", "/system/priv-app/SHealth4/lib/arm64/lib_stressanalyzer_v03_jni.so");
    symlink("/system/lib/libCreateSceneMap.so", "/system/priv-app/VirtualTourViewer_WQHD_lightTheme/lib/arm/libCreateSceneMap.so");
    symlink("/system/lib/libqjpeg_secvision.so", "/system/priv-app/VirtualTourViewer_WQHD_lightTheme/lib/arm/libqjpeg_secvision.so");


Attention: framework deodexed only for 64-bit (32-bit version not deodexed and not was copied to result)

List of apks that have 32-bit and 64-bit versions (deodexed only for 64-bit):

    /system/app/WebViewGoogle.apk


List of deodexed apks that have only 32-bit version (don't have 64-bit):

    /system/app/AdvSoundDetector2015.apk
    /system/app/AllshareFileShare.apk
    /system/app/AllshareFileShareServer.apk
    /system/app/AllshareMediaShare.apk
    /system/app/Bluetooth.apk
    /system/app/Panorama360Viewer_Zero.apk
    /system/app/RootPA.apk
    /system/app/SamsungChineseIMEv9.apk
    /system/app/SapaMonitor.apk
    /system/app/SBrowser_3.0.38.apk
    /system/app/SCONE_Android_ProxyService_Lib.apk
    /system/app/SecDict2Zero.apk
    /system/app/TuiService.apk
    /system/priv-app/ChineseLanguagePack.apk
    /system/priv-app/EnglishLanguagePack.apk
    /system/priv-app/KoreanLanguagePack.apk
    /system/priv-app/OutOfFocusViewer_WQHD_K.apk
    /system/priv-app/S-Voice_Android_new.apk
    /system/priv-app/SVoice_PLM_Service.apk
    /system/priv-app/TouchWizHome_ZERO.apk
    /system/priv-app/VirtualTourViewer_WQHD_lightTheme.apk
    /system/priv-app/VoiceWakeUp.apk


List of originally deodexed (within stock firmware) files, are left as they were originally:

    /system/framework/cneapiclient.jar
    /system/framework/com.qti.dpmframework.jar
    /system/framework/com.quicinc.cne.jar
    /system/framework/com.samsung.device.jar
    /system/framework/dpmapi.jar
    /system/app/FactoryCamera_FB.apk
    /system/app/minimode-res.apk
    /system/app/MirrorLink.apk
    /system/app/SecFactoryPhoneTest.apk
    /system/app/secvisualeffect-res.apk
    /system/priv-app/AutomationTest_FB.apk
    /system/priv-app/AutoPreconfig.apk
    /system/priv-app/DeviceKeystring.apk
    /system/priv-app/DeviceTest.apk
    /system/priv-app/HwModuleTest.apk
    /system/priv-app/KLMSAgent.apk
    /system/priv-app/serviceModeApp_FB.apk
    /system/priv-app/ServiceModeApp_RIL.apk
    /system/priv-app/SMCore.apk
    /system/framework/core-libart.jar
1. Download for 32-bit systems (v3.5 from 20-07-2015): View attachment SVADeodexerForArtx32.zip
2. Download for 64-bit systems (v3.5 from 20-07-2015): View attachment SVADeodexerForArtx64.zip

This tool uses oat2dex.jar (v0.83) (thanks @_riddle).
If _riddle issues new version of oat2dex.jar - you must change it in zip archive and rename as oat2dex.jar.
 
Last edited:

_alexndr

Senior Member
Mar 1, 2013
2,792
17,475
203
@svadev
Very interesting work, but requires polishing. Unfortunately apks doesn't work after replacing originals and removing arm folder (I've tried replacing these singly, because I have KNOX 0x0 and replacing the whole ROM with framework was to risky for me)

E.g. @sorg's deodexed Lollipop ROM (G900FXXU1BNL2) works fine, I mean every single app I tested works fine after replacing


EDIT:
Have you applied the patch for ART?
https://code.google.com/p/smali/issues/detail?id=225


EDIT2:
Version 2.x works like a charm :)
 

Attachments

Last edited:

tdunham

Recognized Contributor
Jun 21, 2008
13,686
36,462
0
TampaBay
Only trying to get framework files working right now, and I am getting bad checksum messages in logcat examples:

Code:
[ 12-15 16:28:15.507  2937: 2937 W/dex2oat  ]
Failed to open .dex from file '/system/framework/core-libart.jar': Failure to verify dex file '/system/framework/core-libart.jar': Bad checksum (e7501d3a, expected fc15f069)

[ 12-15 16:28:15.507  2937: 2937 W/dex2oat  ]
Failed to open .dex from file '/system/framework/conscrypt.jar': Failure to verify dex file '/system/framework/conscrypt.jar': Bad checksum (a8732526, expected 0f5300f6)

[ 12-15 16:28:15.517  2937: 2937 W/dex2oat  ]
Failed to open .dex from file '/system/framework/okhttp.jar': Failure to verify dex file '/system/framework/okhttp.jar': Bad checksum (06a896a1, expected 40fc93a6)

[ 12-15 16:28:15.527  2937: 2937 W/dex2oat  ]
Failed to open .dex from file '/system/framework/bouncycastle.jar': Failure to verify dex file '/system/framework/bouncycastle.jar': Bad checksum (ee1833bd, expected 2bd04bc7)
 
Last edited:
  • Like
Reactions: _alexndr and svadev

svadev

Senior Member
Dec 13, 2014
133
481
93
@svadev
Very interesting work, but requires polishing. Unfortunately apks doesn't work after replacing originals and removing arm folder (I've tried replacing these singly, because I have KNOX 0x0 and replacing the whole ROM with framework was to risky for me)

E.g. @sorg's deodexed Lollipop ROM (G900FXXU1BNL2) works fine, I mean every single app I tested works fine after replacing


EDIT:
Have you applied the patch for ART?
https://code.google.com/p/smali/issues/detail?id=225
@_alexndr, @tdunham - thanks tor testing.

I will be to work to detect error .
 
Last edited:

svadev

Senior Member
Dec 13, 2014
133
481
93
Only trying to get framework files working right now, and I am getting bad checksum messages in logcat examples:

Code:
[ 12-15 16:28:15.507  2937: 2937 W/dex2oat  ]
Failed to open .dex from file '/system/framework/core-libart.jar': Failure to verify dex file '/system/framework/core-libart.jar': Bad checksum (e7501d3a, expected fc15f069)

[ 12-15 16:28:15.507  2937: 2937 W/dex2oat  ]
Failed to open .dex from file '/system/framework/conscrypt.jar': Failure to verify dex file '/system/framework/conscrypt.jar': Bad checksum (a8732526, expected 0f5300f6)

[ 12-15 16:28:15.517  2937: 2937 W/dex2oat  ]

@
Failed to open .dex from file '/system/framework/okhttp.jar': Failure to verify dex file '/system/framework/okhttp.jar': Bad checksum (06a896a1, expected 40fc93a6)

[ 12-15 16:28:15.527  2937: 2937 W/dex2oat  ]
Failed to open .dex from file '/system/framework/bouncycastle.jar': Failure to verify dex file '/system/framework/bouncycastle.jar': Bad checksum (ee1833bd, expected 2bd04bc7)
@tdunham
I have carefully checked my program algorithm, but not find any error.
Please, try set "Extract dex-files only" checkbox and then manually deodex (with patched smali/backsmali) framework and then test it.
if it will work - then original packed in oat files is not dex but odex.
 

_alexndr

Senior Member
Mar 1, 2013
2,792
17,475
203
Last edited:
  • Like
Reactions: Hilda.I

svadev

Senior Member
Dec 13, 2014
133
481
93
Same case as in my attached logcat

Code:
Suppressed: java.io.IOException: Failure to verify dex file '/system/priv-app/SecMms_Candy/SecMms_Candy.apk': Bad checksum (fa8a09fd, expected b0e743d0)
EDIT
@svadev
Have you read this? (post #54)

http://forum.xda-developers.com/showthread.php?p=57316935
Yes, therefore, me please - try set "Extract dex-files only" checkbox and then manually deodex (with patched smali/backsmali)
for example, SecMms and then test it.

If it will be work - then me will correct my program
 

Golv

Recognized Developer
Jan 17, 2012
2,112
4,394
203
Yes, therefore, me please - try set "Extract dex-files only" checkbox and then manually deodex (with patched smali/backsmali)
for example, SecMms and then test it.

If it will be work - then me will correct my program
Try to use this jar for boot.oat
There are odex files for each jar from framework in output folders.
Files from odex folders beksmaled well.
Share the jar.
java -jar bootoat2dex.jar boot.oat
It will output to 2 folders odex and dex(de-optimized)
I have tested pack these dex to original jar and push into device,
device can boot normally.
Post #12 with attached jar.
https://code.google.com/p/smali/issues/detail?id=225
 
Last edited:

svadev

Senior Member
Dec 13, 2014
133
481
93
Try to use this jar for boot.oat


Post #12 with attached jar.
https://code.google.com/p/smali/issues/detail?id=225
I try it, but it not works with boot.oat for g900fd.

All I figured out why it doesn't work.
Yes, dex-files packed into the oat is ODEX-files. And they need to pass through baksmali and smali. But since there are no properly working smali/baksmali, you have to wait until they appear. As soon as a new version of smali/baksmali - I will make a new, properly working version.
 
Last edited:

Golv

Recognized Developer
Jan 17, 2012
2,112
4,394
203
I try it, but it not works with boot.oat for g900fd.
. But since there are no properly working smali/backsmali, you have to wait until they appear. As soon as a new version of smali/backsmali - I will make a new, properly working version.
But patched 203 smali/baksmali works very well with this decompress odex.
 

_alexndr

Senior Member
Mar 1, 2013
2,792
17,475
203
Yes, therefore, me please - try set "Extract dex-files only" checkbox and then manually deodex (with patched smali/backsmali)
for example, SecMms and then test it.

If it will be work - then me will correct my program
Unfortunatelly, it does not work also after deodexing extracted files (I've used patched by @ sorg (bak)smali tools)

Code:
baksmali-art -a 21 -x SecMms_Candy.apk.dex -o SecMms_Candy

smali-art -a 21 SecMms_Candy -o classes.dex
(bak)smali-art.bat are simply my *.bat files which calls sorg's patched jar files (java -jar [filename].jar %1 %2 %3 .... etc)
 

Attachments

svadev

Senior Member
Dec 13, 2014
133
481
93
Unfortunatelly, it does not work also after deodexing extracted files (I've used patched by @ sorg (bak)smali tools)

Code:
baksmali-art -a 21 -x SecMms_Candy.apk.dex -o SecMms_Candy

smali-art -a 21 SecMms_Candy -o classes.dex
(bak)smali-art.bat are simply my *.bat files which calls sorg's patched jar files (java -jar [filename].jar %1 %2 %3 .... etc)
the fact of the matter is that if backsmali (with pached backsmali) sorg's classes.dex and my classes.dex for secmms and compare it you can see difference.
And soon will become clear
 

tdunham

Recognized Contributor
Jun 21, 2008
13,686
36,462
0
TampaBay
@tdunham
I have carefully checked my program algorithm, but not find any error.
Please, try set "Extract dex-files only" checkbox and then manually deodex (with patched smali/backsmali) framework and then test it.
if it will work - then original packed in oat files is not dex but odex.
Ok, I tested with "Extract dex-files only".
Only tested with 31 files from boot.oat.
ALL 32 output files from boot.oat are not odex, they are dex. I can rename each one to classes.dex, insert into original jar and they decompile fine so they are not odex.
 

svadev

Senior Member
Dec 13, 2014
133
481
93
Ok, I tested with "Extract dex-files only".
Only tested with 31 files from boot.oat.
ALL 32 output files from boot.oat are not odex, they are dex. I can rename each one to classes.dex, insert into original jar and they decompile fine so they are not odex.
Why 31?
framework.jar - has two classes.dex and classes2.dex
 
  • Like
Reactions: tdunham