[Android Q&A, Help & Troubleshooting] Rolto:
Hi,

I am trying to debug an Eclipse project linked to Unity with a plugin. The Eclipse project works on my device (Alcatel One Touch 997), it connects to facebook and shows the user name. But once connected as a plugin to Unity, it does not work anymore. I don't understand the errors from the logcat, or the weird message from Unity about the "portrait" mode (the orientation is set to portrait in the unity settings and in the manifest) :

from Unity :

Unable to find unity activity in manifest. You need to make sure orientation attribut is set to portrait manually.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

from the logcat :

V/ActivityManager( 250): New app record ProcessRecord{41d57940 20062:com.firstandroidapp/10114} thread=android.os.BinderProxy@41fcb530 pid=20062
D/PowerManagerService( 250): setKeyboardVisibility: false
V/ActivityManager( 250): ACT-Launching: ActivityRecord{41d4f3a8 com.firstandroidapp/.MainActivity}
D/NetworkPolicy( 250): onRecv: MSG_FOREGROUND_ACTIVITIES_CHANGED pid:uid:act=20062:10114:true
V/WindowManager( 250): Changing focus from Window{4199c6c8 com.jrdcom.launcher/com.jrdcom.launcher.Launcher paused=false} to null
I/WindowManager( 250): Losing focus: Window{4199c6c8 com.jrdcom.launcher/com.jrdcom.launcher.Launcher paused=false}
D/OpenGLRenderer( 515): Flushing caches (mode 1)
D/OpenGLRenderer( 515): Flushing caches (mode 0)
D/ActivityThread(20062): BIND_APPLICATION handled : 0 / AppBindData{appInfo=ApplicationInfo{418319c8 com.firstandroidapp}}
I/dalvikvm(20062): Failed resolving Lcom/firstandroidapp/MainActivity$1; interface 103 'Lcom/facebook/Session$StatusCallback;'
W/dalvikvm(20062): Link of class 'Lcom/firstandroidapp/MainActivity$1;' failed
E/dalvikvm(20062): Could not find class 'com.firstandroidapp.MainActivity$1', referenced from method com.firstandroidapp.MainActivity.<init>
W/dalvikvm(20062): VFY: unable to resolve new-instance 113 (Lcom/firstandroidapp/MainActivity$1;) in Lcom/firstandroidapp/MainActivity;
D/dalvikvm(20062): VFY: replacing opcode 0x22 at 0x0003
W/dalvikvm(20062): VFY: unable to find class referenced in signature (Lcom/facebook/Session;)
W/dalvikvm(20062): VFY: unable to find class referenced in signature (Lcom/facebook/SessionState;)
W/dalvikvm(20062): VFY: unable to find class referenced in signature (Lcom/facebook/Session;)
W/dalvikvm(20062): VFY: unable to find class referenced in signature (Lcom/facebook/SessionState;)
W/dalvikvm(20062): VFY: unable to find class referenced in signature (Lcom/facebook/model/GraphUser;)
W/dalvikvm(20062): VFY: unable to find class referenced in signature (Lcom/facebook/Session;)
W/dalvikvm(20062): VFY: unable to find class referenced in signature (Lcom/facebook/SessionState;)
I/dalvikvm(20062): Could not find method com.facebook.Session.getActiveSession, referenced from method com.firstandroidapp.MainActivity.updateUI
W/dalvikvm(20062): VFY: unable to resolve static method 264: Lcom/facebook/Session;.getActiveSession ()Lcom/facebook/Session;
D/dalvikvm(20062): VFY: replacing opcode 0x71 at 0x0000
I/dalvikvm(20062): Could not find method com.facebook.UiLifecycleHelper.onActivityResult, referenced from method com.firstandroidapp.MainActivity.onActivityResult
W/dalvikvm(20062): VFY: unable to resolve virtual method 267: Lcom/facebook/UiLifecycleHelper;.onActivityResult (IILandroid/content/Intent;Lcom/facebook/widget/FacebookDialog$Callback;)V
D/dalvikvm(20062): VFY: replacing opcode 0x6e at 0x0007
E/dalvikvm(20062): Could not find class 'com.facebook.UiLifecycleHelper', referenced from method com.firstandroidapp.MainActivity.onCreate
W/dalvikvm(20062): VFY: unable to resolve new-instance 106 (Lcom/facebook/UiLifecycleHelper;) in Lcom/firstandroidapp/MainActivity;
D/dalvikvm(20062): VFY: replacing opcode 0x22 at 0x0005
I/dalvikvm(20062): Could not find method com.facebook.UiLifecycleHelper.onDestroy, referenced from method com.firstandroidapp.MainActivity.onDestroy
W/dalvikvm(20062): VFY: unable to resolve virtual method 269: Lcom/facebook/UiLifecycleHelper;.onDestroy ()V
D/dalvikvm(20062): VFY: replacing opcode 0x6e at 0x0005
I/dalvikvm(20062): Could not find method com.facebook.UiLifecycleHelper.onPause, referenced from method com.firstandroidapp.MainActivity.onPause
W/dalvikvm(20062): VFY: unable to resolve virtual method 270: Lcom/facebook/UiLifecycleHelper;.onPause ()V
D/dalvikvm(20062): VFY: replacing opcode 0x6e at 0x0005
I/dalvikvm(20062): Could not find method com.facebook.UiLifecycleHelper.onResume, referenced from method com.firstandroidapp.MainActivity.onResume
W/dalvikvm(20062): VFY: unable to resolve virtual method 271: Lcom/facebook/UiLifecycleHelper;.onResume ()V
D/dalvikvm(20062): VFY: replacing opcode 0x6e at 0x0005
I/dalvikvm(20062): Could not find method com.facebook.UiLifecycleHelper.onSaveInstanceState, referenced from method com.firstandroidapp.MainActivity.onSaveInstanceState
W/dalvikvm(20062): VFY: unable to resolve virtual method 272: Lcom/facebook/UiLifecycleHelper;.onSaveInstanceState (Landroid/os/Bundle;)V
D/dalvikvm(20062): VFY: replacing opcode 0x6e at 0x0005
I/dalvikvm(20062): Failed resolving Lcom/firstandroidapp/MainActivity$1; interface 103 'Lcom/facebook/Session$StatusCallback;'
W/dalvikvm(20062): Link of class 'Lcom/firstandroidapp/MainActivity$1;' failed
D/dalvikvm(20062): DexOpt: unable to opt direct call 0x0113 at 0x05 in Lcom/firstandroidapp/MainActivity;.<init>
I/dalvikvm(20062): Failed resolving Lcom/firstandroidapp/MainActivity$2; interface 108 'Lcom/facebook/widget/FacebookDialog$Callback;'
W/dalvikvm(20062): Link of class 'Lcom/firstandroidapp/MainActivity$2;' failed
D/dalvikvm(20062): DexOpt: unable to opt direct call 0x0115 at 0x0c in Lcom/firstandroidapp/MainActivity;.<init>
D/dalvikvm(20062): DexOpt: unable to opt direct call 0x010a at 0x09 in Lcom/firstandroidapp/MainActivity;.onCreate
I/dalvikvm(20062): Failed resolving Lcom/firstandroidapp/MainActivity$3; interface 110 'Lcom/facebook/widget/LoginButton$UserInfoChangedCallback;'
W/dalvikvm(20062): Link of class 'Lcom/firstandroidapp/MainActivity$3;' failed
D/dalvikvm(20062): DexOpt: unable to opt direct call 0x0118 at 0x2f in Lcom/firstandroidapp/MainActivity;.onCreate
D/AndroidRuntime(20062): Shutting down VM
W/dalvikvm(20062): threadid=1: thread exiting with uncaught exception (group=0x40f10258)
D/dalvikvm(20051): threadid=0: all daemons have suspended
D/dalvikvm(20051): VM cleaning up
E/AndroidRuntime(20062): FATAL EXCEPTION: main
E/AndroidRuntime(20062): java.lang.NoClassDefFoundError: com.firstandroidapp.MainActivity$1
E/AndroidRuntime(20062):	at com.firstandroidapp.MainActivity.<init>(MainActivity.java:27)
E/AndroidRuntime(20062):	at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(20062):	at java.lang.Class.newInstance(Class.java:1319)
E/AndroidRuntime(20062):	at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
E/AndroidRuntime(20062):	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2011)
E/AndroidRuntime(20062):	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2124)
E/AndroidRuntime(20062):	at android.app.ActivityThread.access$600(ActivityThread.java:135)
E/AndroidRuntime(20062):	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1248)
E/AndroidRuntime(20062):	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(20062):	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(20062):	at android.app.ActivityThread.main(ActivityThread.java:4645)
E/AndroidRuntime(20062):	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(20062):	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(20062):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
E/AndroidRuntime(20062):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
E/AndroidRuntime(20062):	at dalvik.system.NativeStart.main(Native Method)
D/dalvikvm(20051): threadid=4: freeing
D/dalvikvm( 250): threadid=77: interp stack at 0x4d273000
W/ActivityManager( 250): Force finishing activity com.firstandroidapp/.MainActivity
D/dalvikvm( 250): threadid=77: calling run()
W/AES ( 250): Exception Log handling...
D/dalvikvm(20051): LinearAlloc 0x0 used 1005804 of 8388608 (11%)
D/ADB_SERVICES( 6920): closing because is_eof=1 r=-1 s->fde.force_eof=0
D/PowerManagerService( 250): acquireWakeLock flags=0x1 tag=ActivityManager-Launch
D/AES ( 250): ExceptionLog: notify aed
D/AES ( 250): process : com.firstandroidapp
D/AES ( 250): module : com.firstandroidapp v1 (1.0)
D/AES ( 250):
D/AES ( 250): cause : data_app_crash

This is the manifest file in Unity :

//in Unity, the Manifest file
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="(i cannot post links)res/android" package="com.firstandroidapp">
<application
android:allowBackup="true"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="portrait" >
<activity
android:name="com.firstandroidapp.MainActivity"
android:label="MyApp" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:value="(numbersHidden)" android:name="com.facebook.sdk.ApplicationId"/>
<activity android:name="com.facebook.LoginActivity"></activity>
</application>
</manifest>

This is how I call the plugin (the project is set as a library, and I pasted the .jar from the bin folder in the folder Plugins/Android in my project in Unity) :

if(GUI.Button(new Rect(20,250,150,150), "TEST")) {
Debug.Log("hello facebook");
using (AndroidJavaClass javaClass = new AndroidJavaClass("com.firstandroidapp.MainActivity"))
{
using (AndroidJavaObject activity = javaClass.GetStatic<AndroidJavaObject>("ctx"))
{
activity.Call("testFunc");
}
}
}

and the simple method in Eclipse :

public class MainActivity extends UnityPlayerActivity {
public void testFunc(){
Log.i("test func","test func");
}

The only thing I did was importing the classes.jar (to allow to extend UnityPlayerActivity) in the Eclipse project (Properties > Java Build Path) and I added the FacebookSDK folder as a library (below the checkbox use as a Library in Eclipse, where you can add a folder to add other libraries).

Without facebook, the connection between Unity and Eclipse works fine. But with facebook, the errors above show up.

If anyone would have a slight idea how to debug this, i would really appreciate, I cannot manage to fix this problem.

Thanks