- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Anindya-Nishant · Jun 17, 2016 at 09:21 PM ·
unity5pluginsandroidpluginunity-android
Unity3d Game crashes when use Android plugin
I am following Here this tutorial for getting stepcounter and its works well as android project but when i make the android project as library and want to use in unity3d. it is crashing and give me error class not found:exception.
My unity code is as follows:
void Start () {
#if UNITY_ANDROID
AndroidJNI.AttachCurrentThread();
androidClass = new AndroidJavaClass("com.test.testapp.MainActivity");
#endif
}
#if UNITY_ANDROID
public void checkMyIntOnJava(string message){
if (message == "READY") {
int myInt = androidClass.CallStatic<int>("getMyInt");
guiText.text = "My Int: " + myInt;
}
}
and my android code is as follows:
public class MainActivity extends UnityPlayerActivity
implements OnDataPointListener, GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener
{
public static void callbackToUnityMethod(int num, String gameObject,String methodName){
_myInt = num;
Log.e("GoogleFit", "in callbackToUnityMethod");
UnityPlayer.UnitySendMessage(gameObject, methodName, "READY");
}
}
After making android jaar i keep it in plugin folder in unity3d. Did I miss anything??
Comment