# How to change the Android NDK jni calls dynamically?

Some people are using NativeActivity for working with Android projects exclusively in C++, but this also carries some disadvantages, so I, like many others, decided that I'd use instead a Java glue code; just a single Java file wrapping all things I need from C++, where pretty much everything runs.

With this said, as far as I know, using this Java code forces me to implement the native function calls in Java, where the Java calls a function that is actually called within the C++ part of the project, with the JNI.

In C++, the native function being called has a prototype like this:

JNIEXPORT void Java_com_package_name_nativeTouchDown( JNIEnv*  env, jobject thiz, jfloat x, jfloat y );


My problem is that I started working with scripts exclusively and would like to find a way to not having to recompile the C++ code anymore. So when I want to make a new project, I just copy-paste my C++ compiled code and change the scripts and be allowed to change the package name of the app without any recompilation.

Is this possible somehow? At the point I am at, I simply have to recompile my C++ to conform to a new package name (the one in the format com.company.game). Can't I make C++ fully abstracted from this package name or change it dynamically?

• As I already got an answer that has no relation to the question, let me clarify, I want to compile my engine to a libengine.so that doesn't need to be changed from project to project, as new projects simply are a different collection of scripts and data. Therefore, compiling again libengine.so for every project just because of the package name is not only a hassle but makes automated tasks from the editor a lot more difficult.. – Grimshaw Jul 13 '14 at 22:52

When you write your AndroidManifest.xml you specify both the package for the game and the path to your activity. So use something like com.company.engine for your activity and your C++ and just create a new package name for the game.