Reading Android ABI value in gradle


I have an android project which consumes a C++ SDK. The C++ code is a cmake project and is built by gradle before it uses the output. The linkage is as defined here: Link Gradle to your native library  |  Android Developers

Now the code is successfully building and working, but the problem is that we build our code for multiple ABIs. Within out cmake call, we are required to define the type of architecture for which we are building (something like -DARCH=armv8) as part of arguments.

Now, I have zero experience with gradle, and I was hoping someone could guide me on how I can define the required variable. I tried using application variants, but I couldn’t get far as I didn’t find any documentation of what the structure of it would be.

I know I can define ANDROID_ABI and try doing the work in cmake, but due to how the C++ backend if also being used by the iOS code, I would prefer to keep that logic to gradle.

Thanks in advance. Any help is appreciated.