cnlohr / rawdrawandroid

Build android apps without any java, entirely in C and Make
MIT License
3.55k stars 226 forks source link

How did you know that you could make this work without a `classes.dex` file? #86

Closed ancientstraits closed 2 months ago

ancientstraits commented 2 months ago

I tried this project, and it worked extremely well on my phone with minimal setup. I have spent a few days looking at the code for the project, and learning about the Android build system, and I feel like you have come to such a great length in order to remove all instances of Java code. But I am wondering, how you knew that you could make an APK without any .dex file? In this script and this other script, both create Java files to convert to classes in order to convert them into .dex files, in order to have a classes.dex file in the APK. When I look up information about the classes.dex file, it seems to be "necessary", in order to run an application. But somehow, you were able to make a process that did not ever made a .dex file, yet still have a working Android application! The only actual binary file in the APK is the libcnfgtest.so file that was compiled from all the C files. I am asking how you were able to make this work, despite there being no information on the Internet that it ever could work. Is there some website I am not looking at? Please let me know.

ancientstraits commented 2 months ago

After a lot of research, I was finally able to figure it out, and I am extremely happy. First, after googling "Android APK no DEX", I found the documentation for android:hasCode here, which showed that it was indeed possible to make an application without any classes.dex files. After that, I found this example project from Android themselves that, just like your project, has absolutely no Java in it, and uses android:hasCode="false". I am very impressed at the great lengths you were able to go to in order to research something, and learn that it is possible to make an Android app with absolutely no Java/Kotlin! Thank you so much for all your work.

cnlohr commented 2 months ago

The way I do most of my fun projects is to just start by assuming the thing I want to do can be done. I don't really worry about how feasible it is or how badly I get downvoted on Stack Overflow, and usually the answer is, you can do the thing you think should work. It just might be a little ugly or tricky. Once you have intuition down, just takes time and effort.

Every now and then I'm wrong, but it's pretty rare that I am.

I think I might have found that key in some weird internal Android tool, so I just ran with it.

ancientstraits commented 2 months ago

Thank you very much :)

cnlohr commented 2 months ago

Sorry, I just re-read that, I said "it's pretty rare that I am" and that's not true. I am frequently wrong, but the cost of being wrong is very low, and the payback for being right is astronomically high, so it feels like I'm right a lot when I'm only right maybe 20-30 times per year, with hundreds of times I am wrong.