Short description: How to create an APK and separate libraries (by which I mean a set of classes (and ideally resources) in one form or another, such as JAR, AAR or DEX files), but do not include those libraries in the agro-industrial complex; instead, does the application load them at runtime?
Detail
So, my main question is: how to create such an application (e.g. Gradle). How to specify which classes are included in JAR or DEX files? Am I creating an Android Studio module for every DEX file I want to end in?
A close question is how Java code should then load external libraries and access their classes at runtime. For the latter, I hope that the approach shown in accessing application classes from the dex file by the class loader will work.
I tried the instructions at https://developer.android.com/studio/projects/android-library.html , but this creates an APK that includes a dependency library.
I also tried Multidex ( https://developer.android.com/studio/build/multidex.html ), but this does not seem to leave the developer any control over which classes go into the DEX file and also package them All in one APK. AFAICT cannot control the loading of these DEX files at run time.
Background
There is the possibility of an “ XY problem, ” so I’d better explain the background.
I am creating an application for a client. It will not be distributed through the app store, so it will not have access to the normal update mechanism. Instead, the client wants the application to be able to update itself by downloading new components on its own to replace old components, without having to manually download the new APK manually. The main motive here is that updates should be easy for non-technical users. If an application can control the update process, it can make it smooth and user-friendly.
In addition, the application will be used in areas where Internet access is limited and expensive, so the client wants to be able to release application updates in small pieces (for example, 2 MB), and not force the user to re-download the entire application to receive a small update.
One aspect of the requirements that I should mention in case it matters is that the libraries that need to be loaded at runtime must live on a microSD card. It can also help distribute updates without Internet access.
The current state of the application is that it is written about 50%: that is, a couple of earlier versions were released, but now the application needs to be changed (changed) to meet the above requirements, as well as others,