0
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ 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.. \$\endgroup\$ – Grimshaw Jul 13 '14 at 22:52
1
\$\begingroup\$

Your package name doesn't need to match the package where you put your classes.

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Really? I had no idea about this! This is really helpful, thanks! \$\endgroup\$ – Grimshaw Jul 15 '14 at 10:03
  • \$\begingroup\$ Do you have an example AndroidManifest.xml of how you did this? Thanks! \$\endgroup\$ – user1054922 Apr 16 '17 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.