2012-12-23 45 views
3

我正在做一個測試應用程序,以瞭解我們如何通過Plugin統一使用java代碼。Android Plugin for Unity給出錯誤

我在eclipse中使用Android 3.2創建了一個簡單的Android Activity類。

package com.control.unitycontrol; 
import com.unity3d.player.UnityPlayerActivity; 
import android.os.Bundle; 
import android.util.Log; 
import android.widget.Toast; 
public class MainActivity extends UnityPlayerActivity { 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     Log.d("TEST","Foo method is called is called 1111"); 


    } 

    public static void foo(){ 

     Log.d("TEST","Foo method is called is called 2222"); // this method is never called 



    }} 

這裏是我的AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.control.unitycontrol" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="15" /> 

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/title_activity_main" 
      android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

據我複製classes.jar我的庫文件夾,然後將它添加到我的類路徑教程..

然後我做了我的項目「圖書館」。

最後我將我的unitycontrol.jar和AndroidManifest.xml一起添加到了Assests-> Plugins-> Android文件夾。

訪問我在C#腳本中的代碼我寫道。

using (AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) 


     { 

      using (AndroidJavaObject obj_Activity = cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) 

     { 

       obj_Activity .CallStatic("foo"); 

     } 

    } 

當我打我的情景,我得到錯誤說:

JNI:無法找到 'currentActivity' id字段(靜態) UnityEngine.AndroidJavaObject:GetStatic(字符串)

如果我嘗試構建它,我會收到錯誤消息:

* 無法重新打包資源llowing參數: package -v -f -m -J gen -M AndroidManifest.xml -S「res」-I「C:/ Users/sumit/Documents/android-sdk-windows/platforms/android-16 \ android。 jar「-F bin/resources.ap_ 配置:*

任何幫助... !!!我該怎麼辦才能解決此問題

+0

如果你已經找到解決方案,請分享 –

回答

0

試試刪除AndroidManifest.xml? 對於圖書館來說,它是無用的。

0

從應用程序標記中刪除圖標/主題/標籤,絕對有效。

相關問題