Write simple android plugin for unity

Hi guys, so I have some trouble in unity when I run my simple plugin. It gives me some errors :

Exception: JNI: Init'd AndroidJavaClass with null ptr!
UnityEngine.AndroidJavaClass..ctor (IntPtr jclass) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:556)
UnityEngine.AndroidJavaObject.get_JavaLangClass () (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:534)
UnityEngine.AndroidJavaObject.FindClass (System.String name) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:525)
UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:545)
UnityEngine.AndroidJavaClass..ctor (System.String className) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/AndroidJavaBindings.gen.cs:94)
Test.EventAndroid () (at Assets/Test.cs:23)
UnityEngine.Events.InvokableCall.Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:144)
UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:621)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:756)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:53)
UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:35)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:44)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:52)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)

I have no idea what’s the cause of this problems. But I’m guessing that the cause of that problems is maybe because I’m using someone’s old post to make it. This is my reference. It’s written in chinese language so I translated it with the help from google translate. Thank you.

Why dont you follow an example not in Chinese. There are plenty. I know they are out there as I wrote an Android plugin.

No, im not googling it for you.

1 Like

I’ll google the error for them though…

http://lmgtfy.com/?q=Exception:+JNI:+Init’d+AndroidJavaClass+with+null+ptr!

Oh, what’s that as the first several results? It looks like that error appears when you try to run code attempting to access the Android APK from the editor

well yeah you’d get a null pointer… there’s no android device to access!

And that’s why I have this tattoo:

1 Like

but sir @lordofduck my android device can’t even run that .apk … always force closed when I run it

it’s duct, as in duct tape:

I’m not sure why it doesn’t run on your android device, but if it can’t even run on your android device… that’s probably your problem. Unity isn’t the hiccup here… it’s that APK.

idk if that’s so fashionable in your country lol, but yea maybe i’ll just let it be a mystery for now… thread closed

It was 20 years ago… it was a ‘phase’.

Anyways, so you’re going to deal with your android issue then?

yea, what more can I do ? I can’t handle the issue related to technical error.
So maybe I’ll just trying some others android plugin tutorial and hoping that it doesn’t give me same issue like this.

haha, @lordofduct you’re my new favorite member on the forums lol