5
0

UnityでAndroid13から14へアップデートする際に起きたこととその解決法

Posted at

始めに

Android13から14へアップデートする手順は、
ProjectSetting>OtherSetting>Target API Level を33から34へ変更。
ビルド時に34用のSDKが無いとエラーが出るのでそのままUpdateを選択。

32から33はこのままで問題なかったが、今回は起動時にクラッシュするようになってしまった。
エラーと解決した方法を載せていく。

AndroidStudioをインストール

「GooglePlayConsoleのリリース前レポートにエラーは出るが、中断したというエラーしかなく詳細は分からない」ということがあった為、インストール
Logcatにログが出る為、鮮明にエラーが分かった。

エラー① No pending exception expected: java.lang.NoSuchMethodError

Logcatに以下のエラーが出た。
AssetPackManagerでメソッドが見つからなかったというエラー。

No pending exception expected: java.lang.NoSuchMethodError: 
No interface method getPackStates(Ljava/util/List;)Lcom/google/android/gms/tasks/Task; 
in class Lcom/google/android/play/core/assetpacks/AssetPackManager; 
or its super classes (declaration of 'com.google.android.play.core.assetpacks.AssetPackManager') 

これはGooglePlayPluginを最新バージョンにすることによって解決した。
ここから最新のPlay Asset Deliveryをダウンロードして上書きをした。

エラー② Update your Play Core Maven dependency to an Android 14 compatible version!

以下は、GooglePlayConsoleの受信トレイに来ていたもの。
依存関係を更新してほしいとのこと。

Update your Play Core Maven dependency to an Android 14 compatible version! 
Your current Play Core library is incompatible with targetSdkVersion 34 (Android 14), 
which introduces a backwards-incompatible change to broadcast receivers to improve user security.
As a reminder, from August 31, Google Play requires all new app releases to target Android 14. 
Update to the latest Play Core library version dependency to avoid app crashes: 
https://developer.android.com/guide/playcore#playcore-migration

公式サイトを参考にgradleファイルを書き換えていく。
gradleファイルについては公式ドキュメント場所を参考に。

dependencies {
   
    implementation 'com.google.android.play:asset-delivery:2.2.1'

**DEPS**}

エラー③ AndroidJavaException: java.lang.NoClassDefFoundError

Logcatに以下のエラーが出た。

AndroidJavaException: java.lang.NoClassDefFoundError: 
Failed resolution of: 
Landroidx/activity/result/ActivityResultLauncher;

ActivityResultLauncherというのが見つからないらしい。
これはgradleに直接入力して解決した。

dependencies {
   
    def activity_version = "1.6.0"
    implementation "androidx.activity:activity:$activity_version"

**DEPS**}

エラー④ JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception java.lang.NoSuchMethodError

'JNI DETECTED ERROR IN APPLICATION: 
JNI NewStringUTF called with pending exception java.lang.
NoSuchMethodError: No interface method getPackStates
(Ljava/util/List;)Lcom/google/android/gms/tasks/Task; 
in class Lcom/google/android/play/core/assetpacks/AssetPackManager; 
or its super classes (declaration of 'com.google.android.play.core.assetpacks.AssetPackManager')

com/google/android/gms/tasks/Task で getPackStates が見つからないらしい。
同様のバグのサイトを参考にすると、Unity固有のエラーらしく、Unityのバージョンを更新したら解決した。

最後に

同じように困っている方の力になれば幸いです。

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0