Problem when try to call Unity method from Android

Hi all,
I create one Unity project and I add it in my Android Layout. Everything work very well.
I have problem when I try to use UnityPlayer.UnitySendMessage(“GameObject”, “method”, “message”) for call c# method from my Android project. I receive the following error: Object Jump not found!.
I read lots of similar questions but anyone help me.

  1. In Unity I have a gameobject call
    Jump
  2. The name of c# class is Jump
  3. I Build an android project and add Staging Area folder in Eclipse (by
    creating new android project)
  4. this project is mark as library
  5. I add classes.jar in my library

I show you my android code:

package com.example.footm;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.app.Activity;
import android.os.Bundle;

import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;
//Studio dei movimenti del soggetto

public class AvatarUnity extends UnityPlayerActivity {
	
	UnityPlayer mUnityPlayer;
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		MachineState.Avatar_Thread_isRunning = true;
		Thread AvatarThread = new Thread(new Runnable(){

			@Override
			public void run() {
				String start_string = "s";
        		OutputStream os;
        		byte[] byte_start = new byte[start_string.length()];
    			byte_start=start_string.getBytes();
    			try {
					
					 os = MachineState.socket.getOutputStream();
					 os.write(byte_start);
					 os.flush();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					MachineState.Avatar_Thread_isRunning=false;
					e1.printStackTrace();
				}
    			byte[] buffer_dati = new byte[1024];
				int count_bytes_read;
				int Pressure_back;
        		int Pressure_front;
        		//Valori baseline di pressione di un soggetto in piedi (punta e tacco della scarpa)
        		int soglia_front = 120;
        		int soglia_back = 120;
        		
        		InputStream is;
				try {
					is = MachineState.socket.getInputStream();
					while((count_bytes_read = is.read(buffer_dati))!=-1 && MachineState.Avatar_Thread_isRunning){
						String data = new String(buffer_dati,0,count_bytes_read);
						if(data.length()==19){
							Pressure_back = Integer.parseInt(data.substring(10, 13), 16);
							Pressure_front = Integer.parseInt(data.substring(13, 16), 16);
							if(Pressure_back>soglia_back && Pressure_front>soglia_front){

								doJump();
								
								
							}
							
						}
					}
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				
			}
			
		});
		AvatarThread.start();
		

	}
	
	@Override
	public void onBackPressed(){
		Activity a = new Activity();
		a.onBackPressed();
	}
	
	public static void doJump(){
		com.unity3d.player.UnityPlayer.UnitySendMessage("Jump", "performJump", "doJump");
	}
}

and this is my Unity code:

using UnityEngine;
using System.Collections;

public class Jump : MonoBehaviour {

	AndroidJavaClass androidClass;
	// Use this for initialization
	void Start () {
		AndroidJNIHelper.debug = true; 
		using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { 
				jc.CallStatic ("UnitySendMessage", "Jump", "performJump", "doJump"); 
		}
//		AndroidJNI.AttachCurrentThread ();
//		androidClass = new AndroidJavaClass("com.example.footm.Avatar");

	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public void performJump(string message){
		//Void esecuzione salto
		GameObject go2 = GameObject.Find ("myHumanoid");
		Animator anim = go2.GetComponent<Animator> ();
		anim.Play ("jump_1");
	}
}

Can someone help me? Thank you all.

Plugin integration is not very easy, if you do some very small mistake it didn’t works and is very difficult to debug. But it works.

I don’t saw any real problem. Unfurtunally you will need to debug. Add System.out.println messages in the java side and Debug.Log on unity3d to understand how it is going. Expecially when send and receive messages.

You will need to use adb logcat to whach the messages.

You can set “adb shell setprop debug.checkjni 1” to force more verbose output from jni calls.

It is always good to tke a second look on official documentation link text

And in some already working examples. This example have both sides communication. link text