[G2 Android Development] MidnightHarvester:
[Tool/Utility][v1.2.0]Apktool Mobile Batch Deodexing - Run Batch Deodex Jobs Using Your Android Device!

*** Disclamer

Your device is shipped without root for a reason. Modifying system files that are normally off limits carries the risk of being caught in a situation where you will be unable to fix the damage unless you plan ahead.

It is wise to not proceed unless you have a means of restoring your device in the event of a catastrophic event and that you are confident in your ability to restore any issues you create.

I am not and will not be responsible for any harm that may come to your device or to your sanity as a result of **** up.

For more on what's expected, new members should help themselves to the video below.

[YOUTUBE]JmvCpR45LKA[/YOUTUBE]

Description

A toolset for performing batch deodexing straight from your device. Comes installable as a flashable zip and can easily be modified by advanced users to suit their needs. Just drop all your odex and corresponding archives into a folder and run one simple terminal command (or use Linux Script Handler within your File Manager) and deodezed versions will be outputted to a separate folder.

I wrote this because Apktool Mobile lacks any batch features.

COMPATIBLE FOR ALL ANDROID DEVICES RUNNING ICS OR LATER!

Project is just listed here because I had to choose a location specific to a certain device when creating the project. Mods, feel free to move if desired.

Learn more about deodexing and the differences between an odexed system and deodexed system

Installed Files/Directories:

/sdcard/bdt - Directory with our smali and baksmali jars as well as directories to place batch jobs in as well as output folders. There is a readme in each folder describing it's function.

/data/misc/bdt - Directory which contains the Java Runtime Environment as well as all dependent libraries.

/system/bin - Two scripts are installed here. The first is "bdt" and contains all path variables in case you need to edit a path (ex. you download newer smali/baksmali versions to use, or change the name of the bdt directory on your /sdcard). This also contains wrapper functions athat do all the work. The second file is "batch-deodex" and once you have placed your odex (and corresponding apk/jar) files into the /sdcard/bdt/files-to-deodex folder open a command prompt and run this script to deodex all the odex files into dex files and then insert into the corresponding archive.

Installation Instructions and Usage

Download the latest version from one of the hosts in the downloads section and simply flash it in recovery. You could always manually extract the contents but then you'd also have to chmod quite a bit to set the permissions.

To uninstall, flash the uninstall zip that's also in the downloads section, or manually delete /system/bin/bdt, /system/bin/batch-deodex, /data/misc/bdt folder, and /sdcard/bdt folder.

Batch baksmali/smali

To run a batch decompile, move your odex (or deodexed apk or jars) files into /sdcard/bdt/files-to-deodex and fire a command prompt up and type:

su
. /system/bin/bdt # Import paths and functions
batch-baksmali

The source folders will be outputted to /sdcard/bdt/smali-source.

To compile a batch of deodexed source folders we just do essentially the same thing. Open up a command prompt and type:

su
. /system/bin/bdt
bbdth-smali

Doing so will create a dex file for each source folder and this will be outputted to /sdcard/bdt/dex-out.

Batch deodexing

Performing a batch deodex works much the same way. Copy all the odex files and their corresponding apk or jar into /sdcard/bdt/files-to-deodex then open a command prompt up and type:

su
# no need to import anything for this
batch-deodex

Just that easy. The script may take a while depending on how many files you're deodexing just as with the other scripts so if running a lot be patient.

The deodex script moves all odex files to ../files-to-baksmali and then calls batch-backsmali. Then the script calls batch-smali to create the dex files. After that's done it enumerates through the dex files and finds each one's corresponding archive and once it does it uses the

zip -jq {archive} classes.dex

to insert classes.dex into the archive without extracting anything or changing any compression settings, etc.

Once complete you'll have your deodexed archives and the script cleans up all other directories. The other two scripts don't do this.

Known Issues

-- Discovered that some ROMs are telling me that my scripts don't exists when they very well do, so of you are seeing a "sh: {scriptname}: The file or directory cannot be found" then just run by using the Linux Script Handler within your File Manager until I figure this out or until the ROM dev gets in touch.

-- I just discovered this error while preparing these test screenshots. It didn't effect the deodexing process though but I'll look into fixing this tomorrow. UPDATE: Haven't looked into this yet as it has no effect on the outcome. I think it's occurring because on the final loop when running a batch and when all is finished it still runs one last time, thinking it's looking for a jar file. Once I get these other minor details done I'll publish on github. Actually there is published code there now, but ir needs to be removed and updated.

Downloads

Batch Deodex Tools 1.2.0 - Box

Batch Deodex Tools 1.2.0 - Dropbox

Uninstall ZIP for 1.1.0

Changelog

1.2.0 Released: -- 08/21/14
-- fixed an issue causing the /sdcard/BDT folder to not be properly flashed
-- some editing made to the scripts in preparation for uploading to github

1.1.0 Released: -- 06/26/14
-- turned into a stand alone project
-- optimized the scripts
-- flashable in recovery
-- also created flashable zip to uninstall

1.0.1 Released: -- 06/21/14
-- initial release

TO DO

-- Migrate the JRE off /data/... to prepare for Android L. Was going to move to /data/app-lib where it probably should have been to begin but no point now, so will remain in /data/misc/bdt for the time. Rwas more in the Addendum in second post

-- Add Box, Dropbop, and Mega hosts as well. Well having just a Drive and Box host should accommodate the demand. If the demand increases I'll adjust accordingly.

-- Publish code to github.

-- Scratched making this into an APK... Having it as is makes it easier for advanced users to make modifications (use custom files, etc) on the fly

Thanks To/Credits

* Brut.all for giving us apktool and much more
*

XDA:DevDB Information

Batch Deodex Tools - Android, Tool/Utility for the LG G2

Contributors

MidnightHarvester

Version Information

Status: Stable

Current Stable Version: 1.2.0

Stable Release Date: 2014-08-21

Created 2014-06-22

Last Updated 2014-08-21