facebook twitter hatena line email

Unity/GoogleMobileAds/TestDeviceId自動取得

提供: 初心者エンジニアの簡易メモ
2023年12月28日 (木) 13:22時点におけるAdmin (トーク | 投稿記録)による版 (_AndroidJNIHelper.GetFieldIDエラーが出る場合)

移動: 案内検索

TestDeviceIdを自動で取得

以下のAdMobUtilityのソースを持ってくる。

https://gist.github.com/pantone170145/dca61bb1a2ee5bf3a082

AdMobUtility.GetTestDeviceId(); // これでTestDeviceIdが呼び出せる
AdMobUtility.GetAndroidId();  // AndroidIdはこちらで

_AndroidJNIHelper.GetFieldIDエラーが出る場合

エラー詳細

Exception: Field currentActivity or type signature  not found
UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.String signature,

修正方法

!UNITY_EDITORを追加

#elif UNITY_ANDROID && !UNITY_EDITOR
		return GetAndroidId().CalculateMD5Hash().ToUpper();

== gradle.properties

Configuration `releaseRuntimeClasspath` contains AndroidX dependencies, but the `android.useAndroidX` property is not enabled, which may cause runtime issues. See the Console for details.