Vmob Android support
April 10, 2021 ยท View on GitHub
This doc goes trough requirments what it takes to generate C library for Android target.
JNI
JNI or Java Native Interface is used for Android NDK to communicate with .so library. JNI requires special way of writing C/C++ code that confirms to their rules. JNI uses JNI special types, if we have int in C, now that becomes jInt and so on.
Sample of JNI written code:
First we have to generate JavaToC.h file
/* DO NOT EDIT THIS FILE - it is machine generated */
#include
/* Header for class JavaToC */
#ifndef _Included_JavaToC
#define _Included_JavaToC
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: JavaToC
* Method: helloC
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_JavaToC_helloC
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
Then we have to work on C part
#include "JavaToC.h"
JNIEXPORT void JNICALL Java_JavaToC_helloC(JNIEnv *env, jobject javaobj)
{
printf("Hello World: From C");
return;
}
We have to then compile this into .so library.