Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Plugin for Unity giving errors
    text
    copied!<p>i was doing a test application to learn how we cam use java code in unity through Plugin.</p> <p>I created a simple Android Activity class using Android 3.2 in eclipse.</p> <pre><code>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 }} </code></pre> <p>Here is my AndroidManifest.xml</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.control.unitycontrol" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;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"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>According to the tutorial I copied classes.jar to my libs folder then added it to my classpath..</p> <p>then I made my project "Is Library ".</p> <p>Finally I added my unitycontrol.jar to Assests->Plugins->Android folder along with the AndroidManifest.xml.</p> <p>To Access my code in C# script I wrote.</p> <pre><code>using (AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject obj_Activity = cls_UnityPlayer.GetStatic&lt;AndroidJavaObject&gt;("currentActivity")) { obj_Activity .CallStatic("foo"); } } </code></pre> <p>When i play my scene I get error saying:</p> <p><em><strong>JNI: Unable to find field id for 'currentActivity' (static) UnityEngine.AndroidJavaObject:GetStatic(String)</em></strong></p> <p>If I try to build it I get error saying :</p> <p>*<strong>Failed to re-package resources with the following parameters: 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_ Configurations:*</strong></p> <p>Any Help ...!!! What can I do resolve this Issue</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload