To checkout a different version of loading the DEX files see branch
method2
This project aims to acheive custom class loading in Dalvik as was outlined in the Android Developers Blogpost
I have a gradle wrapper checked in so all you need to do is define a file local.properties
with a variable called sdk.dir
like this:
sdk.dir=Absolute Location of your Android SDK
If you import the project in Android Studio, it would automatically create one for you.
Compile & run. If everything is correct, then you should see a log message in Logcat with the tag: MyLoader
The structure of this project is like this:
-Root Project
|-- app
|-- lib (The secondary Dex Library)
We modify the build.gradle
files to be able to churn out the Dex file for the secondary library
Take a look at app's build.gradle and lib's build.gradle
We then use this and copy it into the assets folder which gets packaged into the final APK.
Once this is done, loading the dex at runtime is easy, and is explained in the blogpost.
A requirement is that both the library and the app will need to maintain a shared interface, otherwise the loading function will need to invoke methods at runtime via reflection.