PR

[Unity]NatShareをExternal Dependency Managerに対応させる方法

Unity

はじめに

SNS共有するのに便利なアセットNatShareですが、FirebaseやAdMob等の他のアセットと同時に組み込むと色々とエラーが発生してしまうケースがありますので、今回はその紹介と解決策としてNatShareをExternal Dependency Managerに対応させる方法を紹介します。

ビルドエラー

これは1例ですがFirebase App (Core)Natshareを組み込んだプロジェクトをAndroidでビルドすると以下のようなエラーになります。

エラーログ


> Configure project :launcher
WARNING: The option 'android.enableR8' is deprecated and should not be used anymore.
It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.15f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.15f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.15f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.1.15f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :launcher:generateReleaseBuildConfig UP-TO-DATE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :launcher:compileReleaseAidl NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :launcher:mainApkListPersistenceRelease UP-TO-DATE
> Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
> Task :unityLibrary:processReleaseManifest
> Task :unityLibrary:generateReleaseRFile UP-TO-DATE
> Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
> Task :unityLibrary:bundleLibCompileRelease UP-TO-DATE
> Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
> Task :unityLibrary:bundleLibRuntimeRelease UP-TO-DATE
> Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
> Task :unityLibrary:compileReleaseShaders UP-TO-DATE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:bundleLibResRelease
> Task :unityLibrary:mergeReleaseJniLibFolders
> Task :unityLibrary:mergeReleaseNativeLibs
> Task :unityLibrary:stripReleaseDebugSymbols
> Task :unityLibrary:copyReleaseJniLibsProjectOnly
> Task :launcher:processReleaseManifest
> Task :launcher:prepareLintJar UP-TO-DATE
> Task :launcher:checkReleaseDuplicateClasses FAILED
> Task :launcher:mergeReleaseResources
> Task :launcher:javaPreCompileRelease
31 actionable tasks: 11 executed, 20 up-to-date

UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

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.v4.app.INotificationSideChannel found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.IResultReceiver found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.ResultReceiver found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.ResultReceiver$1 found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.accessibilityservice.AccessibilityServiceInfoCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$1 found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$OnRequestPermissionsResultCallback found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$PermissionCompatDelegate found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$RequestPermissionsRequestCodeValidator found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$SharedElementCallback21Impl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$SharedElementCallback21Impl$1 found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityManagerCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityOptionsCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityOptionsCompat$ActivityOptionsCompatImpl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.AlarmManagerCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.AppComponentFactory found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.AppLaunchChecker found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.AppOpsManagerCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.BundleCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.BundleCompat$BundleCompatBaseImpl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ComponentActivity found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ComponentActivity$ExtraData found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.CoreComponentFactory found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.CoreComponentFactory$CompatWrapped found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator$FrameMetricsApi24Impl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator$FrameMetricsApi24Impl$1 found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator$FrameMetricsBaseImpl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator$MetricType found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$CommandProcessor found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$CompatJobEngine found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$CompatWorkEnqueuer found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$CompatWorkItem found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$GenericWorkItem found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$JobServiceEngineImpl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$JobServiceEngineImpl$WrapperWorkItem found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$JobWorkEnqueuer found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$WorkEnqueuer found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NavUtils found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationBuilderWithBuilderAccessor found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action$Builder found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action$Extender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action$SemanticAction found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action$WearableExtender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$BadgeIconType found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$BigPictureStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$BigTextStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Builder found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$CarExtender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$CarExtender$UnreadConversation found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$CarExtender$UnreadConversation$Builder found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$DecoratedCustomViewStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Extender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$GroupAlertBehavior found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$InboxStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$MessagingStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$MessagingStyle$Message found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$NotificationVisibility found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$StreamType found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Style found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$WearableExtender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatBuilder found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatExtras found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatJellybean found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatSideChannelService found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatSideChannelService$NotificationSideChannelStub found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationManagerCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationManagerCompat$CancelTask found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
 <message truncated>
CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Unity\Hub\Editor\2020.1.15f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2020.1.15f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.6.4.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

stderr[

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.v4.app.INotificationSideChannel found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.IResultReceiver found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.ResultReceiver found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.ResultReceiver$1 found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.accessibilityservice.AccessibilityServiceInfoCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$1 found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$OnRequestPermissionsResultCallback found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$PermissionCompatDelegate found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$RequestPermissionsRequestCodeValidator found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$SharedElementCallback21Impl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityCompat$SharedElementCallback21Impl$1 found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityManagerCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityOptionsCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ActivityOptionsCompat$ActivityOptionsCompatImpl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.AlarmManagerCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.AppComponentFactory found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.AppLaunchChecker found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.AppOpsManagerCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.BundleCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.BundleCompat$BundleCompatBaseImpl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ComponentActivity found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.ComponentActivity$ExtraData found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.CoreComponentFactory found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.CoreComponentFactory$CompatWrapped found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator$FrameMetricsApi24Impl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator$FrameMetricsApi24Impl$1 found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator$FrameMetricsBaseImpl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.FrameMetricsAggregator$MetricType found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$CommandProcessor found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$CompatJobEngine found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$CompatWorkEnqueuer found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$CompatWorkItem found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$GenericWorkItem found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$JobServiceEngineImpl found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$JobServiceEngineImpl$WrapperWorkItem found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$JobWorkEnqueuer found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.JobIntentService$WorkEnqueuer found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NavUtils found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationBuilderWithBuilderAccessor found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action$Builder found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action$Extender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action$SemanticAction found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Action$WearableExtender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$BadgeIconType found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$BigPictureStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$BigTextStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Builder found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$CarExtender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$CarExtender$UnreadConversation found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$CarExtender$UnreadConversation$Builder found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$DecoratedCustomViewStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Extender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$GroupAlertBehavior found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$InboxStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$MessagingStyle found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$MessagingStyle$Message found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$NotificationVisibility found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$StreamType found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$Style found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompat$WearableExtender found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatBuilder found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatExtras found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatJellybean found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatSideChannelService found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate class androidx.core.app.NotificationCompatSideChannelService$NotificationSideChannelStub found in modules androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and core-1.0.0-rc02-runtime.jar (:core-1.0.0-rc02:)
  Duplicate cl<message truncated>
Build completed with a result of 'Failed'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x0027c] in <507f517ae7864f439b730eed1dbf6793>:0 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <507f517ae7864f439b730eed1dbf6793>:0 
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

このエラーは何が原因かというと「Execution failed for task ‘:launcher:checkReleaseDuplicateClasses’.」とエラーログに書いてある通り、同じライブラリが複数入っている場合に発生します。

プロジェクトフォルダをよく見るとNatSuiteフォルダPluguinsフォルダ内にcore-x.x.x.aarというファイルがあるのがわかります。

このビルドエラーの解決方法はどちらかのcore-x.x.x.aarを削除すれば解決します。

しかしPluginsフォルダ配下はExternal Dependency Managerが管理しているので削除しても復活してしまいます。

必然的にNatSuiteフォルダのcore-x.x.x.aarを削除することになると思います。

NatSuiteフォルダ内のcore-x.x.x.aarを削除するでビルドエラーは解決しますが1つ問題が発生します。

問題点

その問題点とはExternal Dependency Managerの管理からcore-x.x.x.aarのライブラリが外れてしまった際にビルドエラーになってしまう点です。

上記の例のようにNatSuiteとFirebase App(Core)が入ったプロジェクトでNatSuiteのcore-x.x.x.aarを削除してFirebase App(Core)を消した場合にcore-x.x.x.aarがないのでビルドエラーになります。

そこで解決策としてNatShareのcore-x.x.x.aarをExternal Dependency Manager管理にさせたいと思います。

解決策

NatSuiteフォルダにEditorフォルダを用意し以下のxmlファイルを配置してください。

NatSuiteDependencies.xml

<dependencies>
  <androidPackages>
    <androidPackage spec="androidx.core:core:LATEST" />
  </androidPackages>
</dependencies>

この状態で[Assets]→[External Dependency Manager]→[Android Resolver]→[Force Resolve]を押すと。。。

無事にcore-x.x.x.aarのライブラリが入りました!(余計なライブラリも入ったけど。。。)

さいごに

NatShareをExternal Dependency Managerに対応させてみましたがいくつか余計なライブラリも入ってしまいました。この辺りはいずれちゃんと調べたい。

参考

GitHub - googlesamples/unity-jar-resolver: Unity plugin which resolves Android & iOS dependencies and performs version management
Unity plugin which resolves Android & iOS dependencies and performs version management - googlesamples/unity-jar-resolve...

おすすめ参考書

コメント

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