What you are doing is possible - here are the official docs about how to build plain c/c++ code for Android(basically everything you need to know). It won't be gradle building native, though - the build will be dependent on either CMake(supports building for arbitrary platforms) or ndk-build(supports only android native build).
Basically, you have to generate your code into a cpp
folder of your project and Gradle will automatically(almost) know what to do. Well in order to do that you would have to first set up CMake or ndk-build config files.
JNI files generation would be a good idea also, rather than writing all the dull JNI boilerplate manually.
Personally, I was not generating c code but I used the complete set of further steps: setting up build files, compiling, and building. I mostly used official docs for that, with occasional googling, so you ought to be covered here, mate.