Overriding UnityPlayerActivity on Android, Class not found at launch.

So I’m following the section of This Page that describes a way to override UnityPlayerActivity with a custom class. I’ve followed the instructions to the letter, but when I run the application on device it crashes with a ClassNotFoundException on my derived class.

OverrideExample.java:

package com.compnay.testproduct;

import com.unity3d.player.UnityPlayerActivity;

import android.os.Bundle;
import android.util.Log;

public class OverrideExample extends UnityPlayerActivity {

	protected void onCreate(Bundle savedInstanceState) {
		// call UnityPlayerActivity.onCreate()
		super.onCreate(savedInstanceState);
		// print debug message to logcat
		Log.d("OverrideActivity", "onCreate called!");
	}
	
}

I’m then compiling this with the classes.jar from Unity and an android.jar (Version 4.0, API 14, Unity is also set to use this API level). The resulting .class file is then compressed into a .jar with the structure:

OverrideExample.jar/com/company/testproduct/OverrideExample.class

and placed in ./Assets/Plugins/Android.

This Manifest file is also included:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.copmany.testproduct" android:versionName="1.0" android:versionCode="1">
  
	<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  
	<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
    
		<activity android:name=".OverrideExample" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
    
		<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
		</activity>
    
		<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
			<meta-data android:name="android.app.lib_name" android:value="unity" />
			<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
		</activity>
	</application>
	
	<uses-feature android:glEsVersion="0x00020000" />
	<uses-sdk android:minSdkVersion="6" android:targetSdkVersion="16" />
	
</manifest>

And the unfortunate result from logcat:

I/ActivityManager( 1389): Start proc com.copmany.testproduct for activity com.copmany.testproduct/.OverrideExample: pid=30370 uid=10029 gids={3003, 1015}
I/LAB126  ( 1452): StatusBarService hears intent. action: com.lab126.intent.TOP_WINDOW_CHANGED
I/LAB126  ( 1452):  window changed
I/LAB126  ( 1452): don't set softkey config for 'Starting...' window
D/AndroidRuntime(30370): Shutting down VM
W/dalvikvm(30370): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(30370): FATAL EXCEPTION: main
E/AndroidRuntime(30370): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.copmany.testproduct/com.copmany.testproduct.OverrideExample}: java.lang.ClassNotFoundException: com.copmany.testproduct.OverrideExample in loader dalvik.system.PathClassLoader[/mnt/asec/com.copmany.testproduct-1/pkg.apk]

I’ve done some searching and there seem to be a few other people who’ve had my problem, but no solutions have been posted. D=

Thanks for your help! I’ll post the answer if I manage to fix this problem myself.

I’m not sure, but I think the problem could be with your XML file.
Perhaps you should remove the 2nd activity: com.unity3d.player.UnityPlayerActivity.

You don’t need it because .OverrideExample is based on UnityPlayerActivity.

Perhaps you could also lose the 3rd activity: com.unity3d.player.UnityPlayerNativeActivity.

activity android:name=“.OverrideExample”##

must be :
activity android:name=“com.compnay.testproduct.OverrideExample”