Changing package name of an Android* Hybrid App on Eclipse* IDE

Every Android* app is uniquely identified by its package name. So if two apps have a package conflict then the developer will have to change the package name of the app. Eclipse* is the most widely used IDE for Android App development. Below are the steps to follow when you need to convert a Android package name for your hybrid app (which involves native C/C++ code too):

1. Import the project on to Eclipse IDE.
2. Open the AndroidManifest.xml and change the package name like shown below:

From:
<manifest xmlns:android=http://schemas.android.com/apk/res/android package="com.intel.bouncingball" android:versionCode="1" android:versionName="1.0" >
To:
<manifest xmlns:android=http://schemas.android.com/apk/res/android package="com.intel.bouncingballgcc" android:versionCode="1" android:versionName="1.0" >

3. Expand the collapsible src folder in the Project Explorer on Eclipse and right click on the package name under the src folder. Select Refactor > Rename. This action will open the "Rename Package" window where you can mention the new package name (same as the new package name specified in AndroidManifest.xml). Also check "Update textual occurrences in comments and strings (forces preview)"  on that window. Click on "Preview" button, go through the preview and finally click the "Finish" button.
4. The above procedure will only change the plain Java source code. In case of hybrid apps, developer uses the JNI interface provided by Android NDK and this forces C/C++ functions exposed using JNI to follow a specific naming convention. The naming convention is that each function exposed through JNI interface should have its function name prefixed with the fully qualified package name of the Android Activity class in which these functions are declared in Java layer. For instance:

From:

extern "C" {

	JNIEXPORT void JNICALL Java_com_intel_bouncingball_BouncingBallActivity_JNIOnDrawFrame(JNIEnv* env, void* reserved);

	}

To:
extern "C" {

	JNIEXPORT void JNICALL Java_com_intel_bouncingballgcc_BouncingBallActivity_JNIOnDrawFrame(JNIEnv* env, void* reserved);

	}


Following the above steps ensures that your app will use the new package name. With the package name successfully changed, the .apk can be build and deployed using Eclipse.

Kategorien:
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.