4

Is it possible to create an apk without gradle via command line? My application consists of both kotlin and C++ code. Currently I used separate compilers for both kotlin and c++ code and compile them.

Now I also got a requirement of many resource files (like Xml files, png files etc.,).

I have gone through one of the links but they mentioned about 'aapt' and not about 'aapt2' because in Android documentation's command line tools only aapt2 is available.

I have also tried only compiling resource files via aapt2 which gave me some binary file with (.flat/.arsc.flat) extensions. After compiling these resource files I have added these binary files in -cp flag of kotlinc command but faced unresolved reference errors.

Can someone please tell me how to achieve this in a correct way? Help would be appreciated.

Rohan Pande
  • 301
  • 1
  • 5
  • Possible yes, but very complicated, specially aapt2 is efficient but very complicated (you need if I remember correctly at least 3-4 calls with a long number of arguments). The common recommendation for a mixed project (Java/Kotlin + C/C++) is to create a fresh gradle based project that combines everything (uses Andorid NDK for building). – Robert Aug 18 '23 at 06:56
  • Can you please provide the steps/commands? If this is possible @Robert – Rohan Pande Aug 18 '23 at 07:41
  • https://developer.android.com/studio/projects/add-native-code and the other pages in this section "Add C and C++ Code". – Robert Aug 18 '23 at 07:46
  • @Robert I was asking for aapt2 how to compile those resource files? and solve the unresolved reference errors I was able to compile but "R.id.xyz" like these attributes were failing – Rohan Pande Aug 18 '23 at 07:51
  • You really like the hard way. If you want to see how aapt2 is used simply create an Android Studio project , add some of your resources and compile it. While compiling use matching tools for your OS to see what commands are executed (on Windows e.g. Sysinternals ProcessMonitor). Then you will see all the necessary commands. – Robert Aug 18 '23 at 07:58

0 Answers0