UniwebviewをインストールしたらUnityプロジェクトがビルド失敗する件

スポンサーリンク
Unity
スポンサーリンク
↑管理人が個人でUnity+Live2Dで作成しているスマホゲームです

Unity用内部ブラウザーアセットのUniwebviewをインストールするとビルドに失敗して以下のようなエラーが出てしまいます。

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class android.support.customtabs.ICustomTabsCallback found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.ICustomTabsCallback$Stub found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.ICustomTabsCallback$Stub$Proxy found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.ICustomTabsService found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.ICustomTabsService$Stub found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.ICustomTabsService$Stub$Proxy found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.IPostMessageService found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.IPostMessageService$Stub found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.IPostMessageService$Stub$Proxy found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService$Stub found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService$Stub$Proxy found in modules browser-1.2.0-runtime.jar (androidx.browser:browser:1.2.0) and jetified-androidx.browser.browser-1.4.0-runtime.jar (:androidx.browser.browser-1.4.0:)
  Duplicate class android.support.v4.app.RemoteActionCompatParcelizer found in modules core-1.1.0-runtime.jar (androidx.core:core:1.1.0) and jetified-androidx.core.core-1.6.0-runtime.jar (:androidx.core.core-1.6.0:)
  Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules core-1.1.0-runtime.jar (androidx.core:core:1.1.0) and jetified-androidx.core.core-1.6.0-runtime.jar (:androidx.core.core-1.6.0:)
  Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.1.0-runtime.jar (androidx.core:core:1.1.0) and jetified-androidx.core.core-1.6.0-runtime.jar (:androidx.core.core-1.6.0:)
  Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.1.0-runtime.jar (androidx.core:core:1.1.0) and jetified-androidx.core.core-1.6.0-runtime.jar (:androidx.core.core-1.6.0:)
  Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.1.0-runtime.jar (androidx.core:core:1.1.0) and jetified-androidx.core.core-1.6.0-runtime.jar (:androidx.core.core-1.6.0:)
  Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.1.0-runtime.jar (androidx.core:core:1.1.0) and jetified-androidx.core.core-1.6.0-runtime.jar (:androidx.core.core-1.6.0:)
  Duplicate class androidx.annotation.AnimRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.AnimatorRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.AnyRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.AnyThread found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.ArrayRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.AttrRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.BinderThread found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.BoolRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.CallSuper found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.CheckResult found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.ColorInt found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.ColorLong found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.ColorRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.ContentView found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.DimenRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.Dimension found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.DrawableRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.FloatRange found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.FontRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.FractionRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.GuardedBy found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.HalfFloat found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.IdRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.InspectableProperty found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.InspectableProperty$EnumEntry found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.InspectableProperty$FlagEntry found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.InspectableProperty$ValueType found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.IntDef found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.IntRange found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.IntegerRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.InterpolatorRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.Keep found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.LayoutRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.LongDef found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.MainThread found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.MenuRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.NavigationRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.NonNull found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.Nullable found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.PluralsRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.Px found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.RawRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.RequiresApi found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.RequiresFeature found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.RequiresPermission found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.RequiresPermission$Read found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.RequiresPermission$Write found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.RestrictTo found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.RestrictTo$Scope found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.Size found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.StringDef found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.StringRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.StyleRes found in modules annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0) and jetified-androidx.annotation.annotation-1.2.0.jar (androidx.annotation.annotation-1.2.0.jar)
  Duplicate class androidx.annotation.StyleableRes found in modules annotatio<message truncated>

ですが、該当する重複ファイルを探しても検索結果に出てきません。
Uniwebviewは自動で必要ライブラリをGradleに追加してくれますが、プラグインの中に入っているライブラリとの重複はチェックできないので、AdmobやFirebaseなどを入れているとこういうクラスの重複エラーが出てしまうみたいです。

UnityEditor の Custom Main Gradle Template にチェックを入れる。
Assets\Plugins\Android\mainTemplate.gradle の defaultConfig に以下のpackagingOptions を追加。

android {
defaultConfig {
packagingOptions {
exclude '**/libc++_shared.so'
}
}
}

これはダメ。

更にこういうエラーが出てしまいます。

UnityException: Error
mainTemplate.gradle file is using the old aaptOptions noCompress property definition which does not include types defined by unityStreamingAssets constant.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&amp;)

Templateの中のaaptOptionsの中に↓を追加。

noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')

これもダメ。

更にこういうエラーが出てしまいます。

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':launcher:collectReleaseDependencies'.
> Could not resolve all task dependencies for configuration ':launcher:releaseRuntimeClasspath'.
   > Could not find com.google.firebase:firebase-app-unity:6.7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-app-unity/6.7.0/firebase-app-unity-6.7.0.pom
       - https://jcenter.bintray.com/com/google/firebase/firebase-app-unity/6.7.0/firebase-app-unity-6.7.0.pom
       - file:/D:/pto/Documents/CocoCoin2.3/Temp/gradleOut/unityLibrary/libs/firebase-app-unity-6.7.0.jar
       - file:/D:/pto/Documents/CocoCoin2.3/Temp/gradleOut/unityLibrary/libs/firebase-app-unity.jar
       - https://maven.google.com/com/google/firebase/firebase-app-unity/6.7.0/firebase-app-unity-6.7.0.pom

Android ResolverのDelete Installed LibraryをしてからResolveをすると以下のようなエラーが。

Resolution Failed.

Resolution failed because EDM4U could not enable Jetifier in Unity 2020.3 without Custom Gradle Properties Template. Please enable 'Custom Gradle Properties Template' found under 'Player Settings > Settings for Android -> Publishing Settings' menu. Due to changes in Gradle project generated by Unity 2019.3 and above, our recommended way of enabling Jetifier is by injecting properties to Assets/Plugins/Android/gradleTemplate.properties.
If you like to patch this yourself, simply disable 'Patch gradleTemplate.properties' in Android Resolver settings.
UnityEngine.Debug:LogError (object)

custom gradle properties を有効にしてもやはりダメでした。

Preference PanelのUniwebviewの項目の「Kotlinを追加」と「Androidブラウザを追加」のチェックを外して、ライブラリを追加させないようにするとビルドできました。
しかし、実行時にブラウザが出ず、デバッガに以下のようなエラーが出てしまいます。

11-30 12:29:30.155: E/Unity(13289): java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;

kotlinのライブラリが無いようなので、さっきの設定画面でKotlinについてのみチェックを付け直すと、ちゃんとブラウザも表示できました!

1 Star2 Stars3 Stars4 Stars5 Stars (まだ投票されていません)
読み込み中...

コメント

広告ブロッカーを無効にしてください。

タイトルとURLをコピーしました