您好我尝试使用Xamarin
与Unity 3D连接Android应用,因为我希望将SharedPreference
项从Android转移到Unity
。在Unity上我运行此代码:
AndroidJavaObject AJO = null;
void Start () {
new AndroidJavaObject("com.example.exampledata.MainActivity");
}
我在手机上运行并在logcat中收到此错误:
I/Unity (29805): AndroidJavaException: java.lang.ClassNotFoundException: com.example.exampledata.MainActivity
I/Unity (29805): java.lang.ClassNotFoundException: com.example.exampledata.MainActivity
I/Unity (29805): at java.lang.Class.classForName(Native Method)
I/Unity (29805): at java.lang.Class.forName(Class.java:308)
I/Unity (29805): at java.lang.Class.forName(Class.java:272)
I/Unity (29805): at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
I/Unity (29805): at com.unity3d.player.UnityPlayer.a(Unknown Source)
I/Unity (29805): at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
I/Unity (29805): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.exampledata.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.exampledata/base.apk"],nativeLibraryDirectories=[/data/app/com.example.exampledata/lib/arm, /vendor/lib, /system/lib]]
I/Unity (29805): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
I/Unity (29805): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
I/Unity (29805): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
I/Unity (29805): ... 6 m
正如你所看到的,团结无法找到班级。您是否有其他方法可以获得SharedPreference
项或其他方式将Android(在Visual Studio上使用Xamarin构建)与Unity 3D连接?
提前致谢