[CMake] Regarding creation of APK through CMake (CMakeAPK idea)

David Demelier markand at malikania.fr
Tue Oct 23 03:07:06 EDT 2018


Hello,

I'm currently experimenting Android development with CMake without using 
gradle, Android Studio, ant or anything else.

The idea is to use Android's sdk-tools only (aapt, dx, zipalign, apksigner).

The process isn't that hard but consists of several steps. The only real 
question is how should an hypothetical CPackAPK would build the 
application because the user has to write some java code and 
AndroidManifest file.

In a nutshell the process of building an apk consist of:

1. aapt package -f -m -J <input> -M AndroidManifest.xml -S <output> -I 
android.jar
2. javac *.java and output to obj
3. dx --dex --output=classes.dex obj
4. aapt package -f -m -F app.unaligned.apk -M AndroidManifest.xml -S 
<output> -I android.jar
5. apksigner sign --ks debug.keystore --ks-pass "blabla"
6. zipalign -f 4 app.unaligned.apk app.apk

So basically, the 1, 3, 4, 5, 6 steps are quite “easy” to implement in a 
CPackAPK module but I need to dig how the step 2 should be handled by 
that module. Also, we need to incorporate all .so required into the 
output directory as well (this could be done with a simple variable I 
think).

Any opinions are welcome,

Some sources which helped me:

https://medium.com/@authmane512/how-to-do-android-development-faster-without-gradle-9046b8c1cf68
https://stackoverflow.com/questions/41132753/how-can-i-build-an-android-apk-without-gradle-on-the-command-line

Regards

-- 
David


More information about the CMake mailing list