我无法将currentActivity统一起来,并且在设备中运行应用程序后,我收到以下错误

时间:2016-04-27 05:31:18

标签: android unity3d

  

java.lang.NoSuchFieldError:no“Ljava / lang / Object;”字段   类“Lcom / unity / unity3d / player / UnityPlayer”中的“currentActivity”或   它的superclassess com.unity3d.player.UnityPlayer

void Start () 
{
    ajc1 = new AndroidJavaClass(className);
    ajc2 = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
    obj = ajc1.GetStatic<AndroidJavaObject> ("currentActivity");
    adhancrListener = new AndroidJavaClass("com.adhancr.adhancrlistener");
}

public void Initialize()
{
    ajc1.CallStatic<bool> (initFunctionName,obj,null);

}

这是我的android清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adhancr.adhancr" android:versionCode="1"
android:versionName="1.0" >
<application>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:theme="@android:style/Theme.Translucent"
 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|
screenSize|smallestScreenSize"/>
<activity android:name="com.inmobi.androidsdk.IMBrowserActivity"android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|
 screenSize" android:theme="@android:style/Theme.Translucent.NoTitleBar" 
android:hardwareAccelerated="true" />
</application>
</manifest>

1 个答案:

答案 0 :(得分:0)

我得到了答案,我们所要做的就是在Android清单文件中添加统一玩家的活动,你就可以了。

<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
          android:label="@string/app_name">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
  </intent-filter>
  <meta-data android:name="unityplayer.UnityActivity" android:value="true"
  />
  <meta-data
 android:name="unityplayer.ForwardNativeEventsToDalvik"android:value="false"
  />
</activity>