无法通过统一启动活动在Android [英] Cannot start activity on Android through Unity

查看:367
本文介绍了无法通过统一启动活动在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用统一打造一个Android应用程序。

I'm using Unity to create an Android application.

我有两个插件。每个正常工作自己,但是当我想他们都使用它们之间我不能切换的活动。

I have two plugins. Each works fine on its own, but when I want the both of them to be used I cannot switch activities between them.

我已经在过去的10天阅读完所有类似的问题,并试图一切从反编译/编辑/重新编译的Java code,从团结自己做这件事,但没有运气。

I have spent the past ten days reading all similar question and have tried everything from decompiling/editing/recompiling Java code to doing it from Unity itself, but no luck.

下面是最后的code自己编写和错误,我得到的。

Here is the final code I have written, and the errors I get.

我的的Andr​​oidManifest.xml 文件:

   ...

      <activity 
        android:name="com.Company.Game.RRAndroidPluginActivity"
              android:label="My Game">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

      </activity>

    <activity
        android:name="com.codiwans.iab.IAB"
        android:screenOrientation="landscape"   
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
        android:label="My Game IAB" >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>

    </activity>

        ...

下面是团结code(C#中):

Here is the Unity code (in C#):

AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject pm = jo.Call<AndroidJavaObject>("getPackageManager");
AndroidJavaObject intent = pm.Call<AndroidJavaObject>("getLaunchIntentForPackage", 
"com.codiwans.iab.IAB");
jo.Call("startActivity", intent);

下面是错误我得到:

JNI: Unable to find method id for 'getClass'
Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54)

JNI: Unable to find method id for 'getName'
Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54)

JNI: Unable to find method id for 'getName'
Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54)

Caused by: java.lang.NoClassDefFoundError: com/unity3d/player/UnityPlayer$12
at com.unity3d.player.UnityPlayer.setScreenSize(Unknown Source)
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.onDrawFrame(Unknown Source)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
Caused by: java.lang.NullPointerException
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1382)
at android.app.Activity.startActivityForResult(Activity.java:3190)
at android.app.Activity.startActivity(Activity.java:3297)
... 4 more

这两项活动都主要。其中一个是发射器。

Both activities are MAIN. One of them is LAUNCHER.

我可以调用的方法成功地在两个。

I can call methods successfully on both.

我不能,切换活动到非发射台之一,然而得到指定的错误(无法找到身份证'的getClass')。

I can't switch activity to the non-LAUNCHER one, however, getting the error specified (unable to find id for 'getClass').

我觉得自己那么近,又那么远。任何帮助是AP preciated。快要疯了过来!

I feel so close, yet so far. Any help is appreciated. Going crazy over here!

感谢。

推荐答案

您真正的问题是这样的:java.lang.NoClassDefFoundError的:COM / unity3d /播放/ UnityPlayer $ 12个

Your real problem is this: java.lang.NoClassDefFoundError: com/unity3d/player/UnityPlayer$12

无论出于何种原因Java是没有找到这个类在类路径中。一些研究显示,在其他地方,它可能关系到你正在编写对罐子,你正在开发针对版本不匹配。这也可能是因为你没有足够的罐子在正确的地方,或者你使用的是不提供类的版本。

For whatever reason java is not finding that class in your class path. Some research elsewhere showed that it may be related to a mismatch in the jar you're compiling against and the version you're developing against. It could also be that you don't have the jar in the correct place, or the version you're using doesn't provide that class.

我希望这至少有助于在正确的方向指向你。

I hope this at least helps point you in the right direction.

这篇关于无法通过统一启动活动在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆