Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Exception: JNI: Init'd AndroidJavaClass with null ptr! #20

Closed
jianloong92 opened this issue Feb 18, 2014 · 1 comment
Closed

Error Exception: JNI: Init'd AndroidJavaClass with null ptr! #20

jianloong92 opened this issue Feb 18, 2014 · 1 comment

Comments

@jianloong92
Copy link

code:
internal AndroidJavaObject GetActivity() {

        AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        if (jc == null) {
            throw new System.Exception("Could not get class com.unity3d.player.UnityPlayer.");
        }
        AndroidJavaObject activity = jc.GetStatic<AndroidJavaObject>("currentActivity");
        if (activity == null) {
            throw new System.Exception("Could not get class current activity from UnityPlayer.");
        }
        return activity;
    }

problem:
Exception: JNI: Init'd AndroidJavaClass with null ptr!
UnityEngine.AndroidJavaClass..ctor (IntPtr jclass)
UnityEngine.AndroidJavaObject.get_JavaLangClass ()
UnityEngine.AndroidJavaObject.FindClass (System.String name)
UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className)
UnityEngine.AndroidJavaClass..ctor (System.String className)
GooglePlayGames.Android.AndroidClient.GetActivity () (at assets/GooglePlayGames/Platforms/Android/AndroidClient.cs:271)
GooglePlayGames.Android.AndroidClient.RunOnUiThread (System.Action action) (at assets/GooglePlayGames/Platforms/Android/AndroidClient.cs:283)
GooglePlayGames.Android.AndroidClient..ctor () (at assets/GooglePlayGames/Platforms/Android/AndroidClient.cs:63)
GooglePlayGames.PlayGamesClientFactory.GetPlatformPlayGamesClient () (at assets/GooglePlayGames/Platforms/PlayGamesClientFactory.cs:26)
GooglePlayGames.PlayGamesPlatform.Authenticate (ILocalUser unused, System.Action1 callback, Boolean silent) (at assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:157) GooglePlayGames.PlayGamesPlatform.Authenticate (ILocalUser localUser, System.Action1 callback) (at assets/GooglePlayGames/ISocialPlatform/PlayGamesPlatform.cs:132)
GooglePlayGames.PlayGamesLocalUser.Authenticate (System.Action`1 callback) (at assets/GooglePlayGames/ISocialPlatform/PlayGamesLocalUser.cs:36)
Game6_Player.Start () (at assets/game 6/script/Game6_Player.cs:124)

@danielsb
Copy link

Are you trying it on the Unity Editor? You can't test it inside Unity, you need to do it in a device running Android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants