I'm playing with something that uses downloaded code (outside of Google's Play store, so feature delivery isn't an option. And the fact this violated Google Play's terms of service is irrelevant). I have it working reading in a dex file and loading classes from there. I can create an instance of it via reflection. Using an interface, I can use that instance and directly call methods of that interface on that instance. What I'd like to do now is take the build from gradle, split several classes out of the dex file and into their own separate dex file, and repackage the APK with the version of the dex file without those classes. Then I'll write some code to download that file and load it in when needed.
Does anyone know how to remove classes from the dex and create a new dex file with them in it? I know it's possible because in the bad old days techniques like that were needed before multidex became a thing.
I don't know if this is what you want.
Convert all places where you impoprt the class you want to separate into reflection code.
Make the class you want to separate into a separate jar library.
Use after loading the library with URLClassLoader().