Category Archives: JNI

Changing app package for Android in Eclipse

When I started learning to develop Augmented Reality based app on Android I started with Qualcomm’s SDK. As usual I start with sample code provided with any SDK and build upon that. Also that way I am able to check the functionality easily.

Hence I needed to change the name of the package after I built a bit on top of the provided sample app. I found Troubleshooting Resources for Android  useful as it provided the initial directions on how to do that

For example, here’s how you could do this in Eclipse:

  1. Right-click on the package name (src/
  2. Select Refactor > Rename and change the name, for example to
  3. Open the manifest file. Inside the <manifest> tag, change the package name to
  4. Open each of the two Activity files and do Ctrl-Shift-O to add missing import packages, then save each file.
  5. Run the GestureBuilder application on the emulator.

It works well but its not all that you are supposed to do if you are using JNI. There are couple more changes you would need to do:

Java_com_first_second_class_Function( JNIEnv* env, jobject obj)
Change com_first_second to the package name you are changing to. This enables Java would be able to call the native function.

jmethodID functionMethodID = env->GetMethodID(activityClass, “function_name”, “(I)Lcom/first/second/Class;”);
Again change com/first/second to the package name you are changing to. And this enables for native library to call the function in Java.

This should help you get going with package name changes.