I have an android app project. I have a Java class with a main() method that I need to run and that main() method needs to have all of the classes and dependencies from the android project in the classpath.
However, all of the tasks to build the android app will produce an android-compatible output which means that all of the classes that I need are smashed down into .dex files so that the android system can read them.
I need to build all of the code/dependencies for my android app project BUT NOT DEX THEM.
Is there a task I can call that will produce the compiled classes/jars/etc without smashing them into dex files? Like, perhaps the task that comes right before dexing?
Or is there a way I can create a specialized build task that will disable dexing all together so that I can just produce all the classes/jars in normal Java format, so that I can then include those as my classpath when I call my main() method?
I'm very, very new to gradle, so if you answer please try to be specific because I likely am not able to make logical jumps or inferences if your answer is advanced. I've spent like 2 weeks trying to learn gradle to figure out how to solve this problem (which at its core is because there is a bug in the latest version of Android Studio. In previous versions, Android Studio would generate the gradle code needed to run this with the appropriate classpath, but the latest version of Android Studio is generating gradle code that uses deprecated properties and so it horks).
I've been able to figure out how to create a jar of just the classes from my personal code, but it doesn't include the classes from all of the dependencies/libraries.
I've tried 100 different iterations of various gradle configurations and attempts. I don't really have gradle code that I can provide as an example of what I'm trying to do, because I can't seem to find anything close.
Gradle 7.3.3
In other words...
My app code is in com.kenny.stuff. That code depends on com.j256.ormlite which depends on android.* and/or androidx.*.
When my android :app project builds, it will produce app-debug.apk, which DOES NOT contain the .class files for com.kenny.stuff, com.j256.ormlite, androidx.*, etc.
During the android build process, the .class files are smashed down into .dex files because the android dalvik system needs them in that structure. So, the apk contains:
app-debug.apk:
/META-INF
/classes.dex
/classes2.dex
/classes3.dex
and inside those dex files are the smashed together .class files.
but what I need is a jar that is:
what-i-need.jar:
/META-INF
/com/kenny/stuff/Stuff.class
/com/kenny/stuff/OtherStuff.class
/com/j256/ormlite/ORMLiteStuff.class
/com/j256/ormlite/ORMLiteOtherStuff.class
/androidx/*.class
etc.
So, I need to be able to compile and collect dependencies for my android project BUT NOT smash all those .class files down into .dex files.
Context: I use ORMlite in my project, which is a 3rd party library that uses @DatabaseTable annotations on Java classes in order to create database tables that are mapped to the objects. ORMlite relies on a config.txt file which describes the table mappings. That file needs to be generated by one of ORMlite's methods. In order to run it, I need my classes and ormlite in the classpath. ormlite needs the other android classes in the classpath.
I used to be able to do this with a simple feature in Android Studio, wherein I could create a Run Configuration that would let me have all of those things in my classpath and run a main() method which contained the code to generate the config.txt file. However, the latest version of Android Studio has a bug and the gradle code it generates for that Run Configuration crashes. So I need a workaround in which I can run a java class's main() method with all of those app classes in my classpath.