Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Unity2017にAdmobメディエーションでAppLovinSDKをいれたら、UnityEditor上でエラーがでる

More than 3 years have passed since last update.

エラー「Exception: JNI: Init'd AndroidJavaClass with null ptr!」

Exception: JNI: Init'd AndroidJavaClass with null ptr!
UnityEngine.AndroidJavaClass..ctor (System.IntPtr jclass) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:622)
UnityEngine.AndroidJavaObject.get_JavaLangClass () (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:600)
UnityEngine.AndroidJavaObject.FindClass (System.String name) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:591)
UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:611)
UnityEngine.AndroidJavaClass..ctor (System.String className) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/AndroidJavaBindings.gen.cs:92)
AppLovin.getDefaultPlugin () (at Assets/Plugins/AppLovin/AppLovin.cs:106)
AppLovin.SetSdkKey (System.String sdkKey) (at Assets/Plugins/AppLovin/AppLovin.cs:560)
GameSceneSingleton.RequestRewardBasedVideo () (at Assets/Scripts/Common/GameSceneSingleton.cs:232)
GameManager.Awake () (at Assets/Scripts/Common/GameManager.cs:371)

原因は、unitypackageで入れている、applovinの初期化が原因でした。

AppLovin.SetSdkKey(Constant.SDK_APPLOVIN_API_KEY);
AppLovin.InitializeSdk();

この部分

下記のように、UnityEditor上は何も処理しないように分岐するとエラーがなくなりました。

#if UNITY_EDITOR
// Do not process with unityEditor

#elif UNITY_ANDROID
// AppLovin
AppLovin.SetSdkKey(Constant.SDK_APPLOVIN_API_KEY);
AppLovin.InitializeSdk();


#elif UNITY_IOS
#endif

matsuyoro
げーむくりえいたー。 顔は濃いが存在の薄さに悩んでいる。 無敵のエンジニアに出会いたい。 書籍「仕事はたのしいかね」の、大きな事でも試してみればの精神に感銘を受けている。 好きな言葉:好きこそものの上手なれ / 楽は苦の種、苦は楽の種
https://matsudapress.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away