Unityのプレビューでは動作していたのに、Androidスマホだと実行時エラーになったので
その対処法。
️環境
macOS 14.4.1
Unity6
スマホ(Android14)
️エラー内容
FATAL EXCEPTION: main
Process: com.jpn.bestyle.guchi, PID: 17487
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/ProcessLifecycleOwner;
at com.google.unity.ads.UnityAppStateEventNotifier$1.run(UnityAppStateEventNotifier.java:51)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
Caused by: java.lang.ClassNotFoundException: androidx.lifecycle.ProcessLifecycleOwner
... 9 more
️原因
AdMobの設定に不足があるっぽい。
️対処法
@GoogleMobileAdsDependencies.xmlに追記
==== 追記する箇所 ====
<androidPackage spec="androidx.lifecycle:lifecycle-process:2.7.0">
<repositories>
<repository>https://maven.google.com/</repository>
</repositories>
</androidPackage>
================
AUnityで対応OSAndroid14(API34)以上に設定
BUnityで設定を反映
Asset > External Dependency Manager > Android Resolver > Force Resolve
️参考
https://github.com/googleads/googleads-mobile-unity/issues/2645
2024年07月01日
[Unity] Android実機で実行時エラー(ClassNotFoundException: androidx.lifecycle.ProcessLifecycleOwner)
posted by be-style at 21:49| Comment(0)
| Android