Unity 传递 了一个参数给 安卓 没有 参数的 函数,导致报错。
AndroidPlayer(ADB@127.0.0.1:34999) AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='test' signature='(Ljava/lang/String;)V' in class Ljava.lang.Object;
unity编辑器
.cs,调用
...
public static string class_sdk_ = "com.newgamestudio.unitydemolib.testInterface";
...
static void callApi(string apiName, params object[] args)
{
AndroidJavaObject mHySdk = null;
mHySdk = new AndroidJavaObject(class_sdk_);
if (mHySdk != null)
{
Debug.LogError(apiName+" callApi");
Debug.Log(apiName+" callApi 111");
mHySdk.CallStatic(apiName, args);
}
}
...
//调用
//callSdkApi("testFunction","");//错误
//callSdkApi("testFunction", null);//错误
callSdkApi("testFunction");//正解
...
.java方面
public class testInterface
...
public static void testFunction()
{
new AndroidUnityDemo().showToast("/test:");
}
...