I'm trying to build my Android plugin for Unity. But when I do, I get the follow error log in Logcat:
12-11 14:45:38.745: E/AndroidRuntime(26806): FATAL EXCEPTION: main
12-11 14:45:38.745: E/AndroidRuntime(26806): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.marc/com.example.marc.CompassActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.marc.CompassActivity" on path: DexPathList[[zip file "/data/app/com.example.marc-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.marc-1, /vendor/lib, /system/lib]]
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.os.Handler.dispatchMessage(Handler.java:99)
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.os.Looper.loop(Looper.java:137)
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-11 14:45:38.745: E/AndroidRuntime(26806): at java.lang.reflect.Method.invokeNative(Native Method)
12-11 14:45:38.745: E/AndroidRuntime(26806): at java.lang.reflect.Method.invoke(Method.java:525)
12-11 14:45:38.745: E/AndroidRuntime(26806): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-11 14:45:38.745: E/AndroidRuntime(26806): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-11 14:45:38.745: E/AndroidRuntime(26806): at dalvik.system.NativeStart.main(Native Method)
12-11 14:45:38.745: E/AndroidRuntime(26806): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.marc.CompassActivity" on path: DexPathList[[zip file "/data/app/com.example.marc-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.marc-1, /vendor/lib, /system/lib]]
12-11 14:45:38.745: E/AndroidRuntime(26806): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
12-11 14:45:38.745: E/AndroidRuntime(26806): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-11 14:45:38.745: E/AndroidRuntime(26806): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
12-11 14:45:38.745: E/AndroidRuntime(26806): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
12-11 14:45:38.745: E/AndroidRuntime(26806): ... 11 more
I did a search on to why this is happening and I discovered it is because of a problem with my intent. And that I needed to add my activity to my Manifest file. However, this is my manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.marc"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="7" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.example.marc.CompassActivity"
android:label="@string/app_name">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
And from what I can see, my intent is there in the line <activity android:name="com.example.marc.CompassActivity"
unless my thinking behind this is entirely wrong?
Just for completions sake, here is my java file:
package com.example.marc;
import com.unity3d.player.UnityPlayerActivity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Config;
import android.util.Log;
import android.app.Activity;
public class CompassActivity extends UnityPlayerActivity
{
private static final String TAG = "Compass";
private SensorManager mSensorManager;
private Sensor mSensor;
static public float xmag;
static public float ymag;
static public float zmag;
private final SensorEventListener mListener = new SensorEventListener()
{
public void onSensorChanged(SensorEvent event)
{
if (Config.DEBUG) Log.d(TAG,
"sensorChanged (" + event.values[0] + ", " + event.values[1] + ", " + event.values[2] + ")");
xmag = event.values[0];
ymag = event.values[1];
zmag = event.values[2];
}
public void onAccuracyChanged(Sensor sensor, int accuracy)
{
}
};
@Override
protected void onCreate(Bundle icicle)
{
super.onCreate(icicle);
mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
}
@Override
protected void onResume()
{
if (Config.DEBUG) Log.d(TAG, "onResume");
super.onResume();
mSensorManager.registerListener(mListener, mSensor,
SensorManager.SENSOR_DELAY_GAME);
}
@Override
protected void onStop()
{
if (Config.DEBUG) Log.d(TAG, "onStop");
mSensorManager.unregisterListener(mListener);
super.onStop();
}
public static float getX()
{
return xmag;
}
public static float getY()
{
return ymag;
}
public static float getZ()
{
return zmag;
}
}
Again, as per my thinking, this is what I should be passing to my Manifest file, such, it is called "CompassActivity". Clearly though I must have done something wrong otherwise I wouldn't be getting the errors I am. Could someone please tell me what it is I am doing wrong / missing?
edit
Latest LogCat files:
12-11 16:32:16.957: E/AndroidRuntime(29055): FATAL EXCEPTION: main
12-11 16:32:16.957: E/AndroidRuntime(29055): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.marc/com.example.marc.CompassActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.marc.CompassActivity" on path: DexPathList[[zip file "/data/app/com.example.marc-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.marc-2, /vendor/lib, /system/lib]]
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.os.Handler.dispatchMessage(Handler.java:99)
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.os.Looper.loop(Looper.java:137)
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-11 16:32:16.957: E/AndroidRuntime(29055): at java.lang.reflect.Method.invokeNative(Native Method)
12-11 16:32:16.957: E/AndroidRuntime(29055): at java.lang.reflect.Method.invoke(Method.java:525)
12-11 16:32:16.957: E/AndroidRuntime(29055): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-11 16:32:16.957: E/AndroidRuntime(29055): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-11 16:32:16.957: E/AndroidRuntime(29055): at dalvik.system.NativeStart.main(Native Method)
12-11 16:32:16.957: E/AndroidRuntime(29055): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.marc.CompassActivity" on path: DexPathList[[zip file "/data/app/com.example.marc-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.marc-2, /vendor/lib, /system/lib]]
12-11 16:32:16.957: E/AndroidRuntime(29055): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
12-11 16:32:16.957: E/AndroidRuntime(29055): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-11 16:32:16.957: E/AndroidRuntime(29055): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
12-11 16:32:16.957: E/AndroidRuntime(29055): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
12-11 16:32:16.957: E/AndroidRuntime(29055): ... 11 more