UnityでAndroid実機にビルドした際にライブラリ周りで起きたエラーの解決（備忘録）


#環境
Unity ver : 2018.3.2f1

#起こったエラー
Android実機に「Build&Run」で実行した結果、コンソールに以下のエラーが発生しました。

```ruby:Console
CommandInvokationFailure: Unable to convert classes into dex format.
/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/OpenJDK/MacOS/bin/java -Xmx4096M -Dcom.android.sdkmanager.toolsdir="/Users/(ユーザー名)/Library/Android/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -

stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/actions/ItemListIntents;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/actions/NoteIntents;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/actions/ReserveIntents;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/actions/SearchIntents;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/common/AccountPicker;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/common/BlockingServiceConnection;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/common/ConnectionResult;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/common/ConnectionResultCreator;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/common/Feature;

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:614)
	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:310)
	at com.android.dx.command.dexer.Main.runDx(Main.java:288)
	at com.android.dx.command.dexer.Main.main(Main.java:244)
	at com.android.dx.command.Main.main(Main.java:95)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at SDKMain.main(SDKMain.java:136)
Caused by: java.lang.InterruptedException: Too many errors
	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:606)
	... 9 more
]
stdout[
processing archive /Users/(ユーザー名)/(プロジェクト名)/Temp/StagingArea/android-libraries/GoogleMobileAdsPlugin/libs/./unity-plugin-library.jar...
processing com/google/unity/BuildConfig.class...
processing com/google/unity/ads/AdNetworkExtras.class...
processing com/google/unity/ads/Banner.class...
processing com/google/unity/ads/Banner$1.class...
processing com/google/unity/ads/Banner$10.class...
processing com/google/unity/ads/Banner$11.class...
processing com/google/unity/ads/Banner$12.class...
processing com/google/unity/ads/Banner$13.class...
processing com/google/unity/ads/Banner$2.class...
processing com/google/unity/ads/Banner$3.class...
processing com/google/unity/ads/Banner$3$1.class...
processing com/google/unity/ads/Banner$3$2.class...
processing com/google/unity/ads/Banner$3$3.class...
processing com/google/unity/ads/Banner$3$4.class...
processing com/google/unity/ads/Banner$3$5.class...
processing com/google/unity/ads/Banner$4.class...
processing com/google/unity/ads/Banner$5.class...
processing com/google/unity/ads/Banner$6.class...
processing com/google/unity/ads/Banner$7.class...
processing com/google/unity/ads/Banner$8.class...
processing com/google/unity/ads/Banner$9.class...
processing com/google/unity/ads/CustomNativeAd.class...
processing com/google/unity/ads/CustomNativeAd$1.class...
processing com/google/unity/ads/CustomNativeAd$2.class...
processing com/google/unity/ads/Interstitial.class...
processing com/google/unity/ads/Interstitial$1.class...
processing com/google/unity/ads/Interstitial$1$1.class...
processing com/google/unity/ads/Interstitial$1$1$1.class...
processing com/google/unity/ads/Interstitial$1$1$2.class...
processing com/google/unity/ads/Interstitial$1$1$3.class...
processing com/google/unity/ads/Interstitial$1$1$4.class...
processing com/google/unity/ads/Interstitial$1$1$5.class...
processing com/google/unity/ads/Interstitial$2.class...
processing com/google/unity/ads/Interstitial$3.class...
processing com/google/unity/ads/NativeAdLoader.class...
processing com/google/unity/ads/NativeAdLoader$1.class...
processing com/google/unity/ads/NativeAdLoader$2.class...
processing com/google/unity/ads/NativeAdLoader$3.class...
processing com/google/unity/ads/NativeAdLoader$3$1.class...
processing com/google/unity/ads/NativeAdLoader$3$2.class...
processing com/google/unity/ads/NativeAdLoader$3$3.class...
processing com/google/unity/ads/NativeAdLoader$4.class...
processing com/google/unity/ads/PluginUtils.class...
processing com/google/unity/ads/RewardBasedVideo.class...
processing com/google/unity/ads/RewardBasedVideo$1.class...
processing com/google/unity/ads/RewardBasedVideo$1$1.class...
processing com/google/unity/ads/RewardBasedVideo$1$1$1.class...
processing com/google/unity/ads/RewardBasedVideo$1$1$2.class...
processing com/google/unity/ads/RewardBasedVideo$1$1$3.class...
processing com/google/unity/ads/RewardBasedVideo$1$1$4.class...
processing com/google/unity/ads/RewardBasedVideo$1$1$5.class...
processing com/google/unity/ads/RewardBasedVideo$1$1$6.class...
processing com/google/unity/ads/RewardBasedVideo$1$1$7.class...
processing com/google/unity/ads/RewardBasedVideo$1$1$8.class...
processing com/google/unity/ads/RewardBasedVideo$2.class...
processing com/google/unity/ads/RewardBasedVideo$3.class...
processing com/google/unity/ads/RewardBasedVideo$4.class...
processing com/google/unity/ads/UnityAdListener.class...
processing com/google/unity/ads/UnityAdLoaderListener.class...
processing com/google/unity/ads/UnityRewardBasedVideoAdListener.class...
processing archive /Users/(ユーザー名)/(プロジェクト名)/Temp/StagingArea/android-libraries/android.arch.lifecycle.runtime-1.0.0/libs/./classes.jar...
processing android/arch/lifecycle/BuildConfig.class...
processing android/arch/lifecycle/LifecycleRegistry.class...
processing android/arch/lifecycle/LifecycleRegistry$1.class...
processing android/arch/lifecycle/LifecycleRegistry$ObserverWithState.class...
processing android/arch/lifecycle/LifecycleRegistryOwner.class...
processing android/arch/lifecycle/ReportFragment.class...
processing android/arch/lifecycle/ReportFragment$ActivityInitializationListener.class...
processing archive /Users/(ユーザー名)/(プロジェクト名)/Temp/StagingArea/android-libraries/com.android.support.customtabs-26.1.0/libs/./classes.jar...
processing android/support/customtabs/BuildConfig.class...
processing android/support/customtabs/CustomTabsCallback.class...
processing android/support/customtabs/CustomTabsClient.class...
processing android/support/customtabs/CustomTabsClient$1.class...
processing android/support/customtabs/CustomTabsClient$2.class...
processing android/support/customtabs/CustomTabsClient$2$1.class...
processing android/support/customtabs/CustomTabsClient$2$2.class...
processing android/support/customtabs/CustomTabsClient$2$3.class...
processing android/support/customtabs/CustomTabsClient$2$4.class...
processing android/support/customtabs/CustomTabsIntent.class...
processing android/support/customtabs/CustomTabsIntent$1.class...
processing android/support/customtabs/CustomTabsIntent$Builder.class...
processing android/support/customtabs/CustomTabsService.class...
processing android/support/customtabs/CustomTabsService$1.class...
processing android/support/customtabs/CustomTabsService$1$1.class...
processing android/support/customtabs/CustomTabsService$Result.class...
processing android/support/customtabs/CustomTabsServiceConnection.class...
processing android/support/customtabs/CustomTabsServiceConnection$1.class...
processing android/support/customtabs/CustomTabsSession.class...
processing android/support/customtabs/CustomTabsSessionToken.class...
processing android/support/customtabs/CustomTabsSessionToken$1.class...
processing android/support/customtabs/ICustomTabsCallback.class...
processing android/support/customtabs/ICustomTabsCallback$Stub.class...
processing android/support/customtabs/ICustomTabsCallback$Stub$Proxy.class...
processing android/support/customtabs/ICustomTabsService.class...
processing android/support/customtabs/ICustomTabsService$Stub.class...
processing android/support/customtabs/ICustomTabsService$Stub$Proxy.class...
processing android/support/customtabs/IPostMessageService.class...
processing android/support/customtabs/IPostMessageService$Stub.class...
processing android/support/customtabs/IPostMessageService$Stub$Proxy.class...
processing android/support/customtabs/PostMessageService.class...
processing android/support/customtabs/PostMessageService$1.class...
processing android/support/customtabs/PostMessageServiceConnection.class...
processing archive /Users/(ユーザー名)/(プロジェクト名)/Temp/StagingArea/android-libraries/com.android.support.support-compat-26.1.0/libs/./classes.jar...
processing android/support/compat/BuildConfig.class...
processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.class...
processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoApi16Impl.class...
processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoApi18Impl.class...
processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoBaseImpl.class...
processing android/support/v4/app/ActivityCompat.class...
processing android/support/v4/app/ActivityCompat$1.class...
processing android/support/v4/app/ActivityCompat$OnRequestPermissionsResultCallback.class...
processing android/support/v4/app/ActivityCompat$RequestPermissionsRequestCodeValidator.class...
processing android/support/v4/app/ActivityCompat$SharedElementCallback21Impl.class...
processing android/support/v4/app/ActivityCompat$SharedElementCallback23Impl.class...
processing android/support/v4/app/ActivityCompat$SharedElementCallback23Impl$1.class...
processing android/support/v4/app/ActivityManagerCompat.class...
processing android/support/v4/app/ActivityOptionsCompat.class...
processing android/support/v4/app/ActivityOptionsCompat$ActivityOptionsCompatApi16Impl.class...
processing android/support/v4/app/ActivityOptionsCompat$ActivityOptionsCompatApi23Impl.class...
processing android/support/v4/app/ActivityOptionsCompat$ActivityOptionsCompatApi24Impl.class...
processing android/support/v4/app/AlarmManagerCompat.class...
processing android/support/v4/app/AppOpsManagerCompat.class...
processing android/support/v4/app/BundleCompat.class...
processing android/support/v4/app/BundleCompat$BundleCompatBaseImpl.class...
processing android/support/v4/app/BundleUtil.class...
processing android/support/v4/app/INotificationSideChannel.class...
processing android/support/v4/app/INotificationSideChannel$Stub.class...
processing android/support/v4/app/INotificationSideChannel$Stub$Proxy.class...
processing android/support/v4/app/JobIntentService.class...
processing android/support/v4/app/JobIntentService$CommandProcessor.class...
processing android/support/v4/app/JobIntentService$CompatJobEngine.class...
processing android/support/v4/app/JobIntentService$CompatWorkEnqueuer.class...
processing android/support/v4/app/JobIntentService$CompatWorkItem.class...
processing android/support/v4/app/JobIntentService$GenericWorkItem.class...
processing android/support/v4/app/JobIntentService$JobServiceEngineImpl.class...
processing android/support/v4/app/JobIntentService$JobServiceEngineImpl$WrapperWorkItem.class...
processing android/support/v4/app/JobIntentService$JobWorkEnqueuer.class...
processing android/support/v4/app/JobIntentService$WorkEnqueuer.class...
processing android/support/v4/app/NotificationBuilderWithActions.class...
processing android/support/v4/app/NotificationBuilderWithBuilderAccessor.class...
processing android/support/v4/app/NotificationCompat.class...
processing android/support/v4/app/NotificationCompat$Action.class...
processing android/support/v4/app/NotificationCompat$Action$1.class...
processing android/support/v4/app/NotificationCompat$Action$Builder.class...
processing android/support/v4/app/NotificationCompat$Action$Extender.class...
processing android/support/v4/app/NotificationCompat$Action$WearableExtender.class...
processing android/support/v4/app/NotificationCompat$BadgeIconType.class...
processing android/support/v4/app/NotificationCompat$BigPictureStyle.class...
processing android/support/v4/app/NotificationCompat$BigTextStyle.class...
processing android/support/v4/app/NotificationCompat$Builder.class...
processing android/support/v4/app/NotificationCompat$BuilderExtender.class...
processing android/support/v4/app/NotificationCompat$CarExtender.class...
processing android/support/v4/app/NotificationCompat$CarExtender$UnreadConversation.class...
processing android/support/v4/app/NotificationCompat$CarExtender$UnreadConversation$1.class...
processing android/support/v4/app/NotificationCompat$CarExtender$UnreadConversation$Builder.class...
processing android/support/v4/app/NotificationCompat$DecoratedCustomViewStyle.class...
processing android/support/v4/app/NotificationCompat$Extender.class...
processing android/support/v4/app/NotificationCompat$InboxStyle.class...
processing android/support/v4/app/NotificationCompat$MessagingStyle.class...
processing android/support/v4/app/NotificationCompat$MessagingStyle$Message.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatApi16Impl.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatApi19Impl.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatApi20Impl.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatApi21Impl.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatApi24Impl.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatApi26Impl.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatBaseImpl.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatBaseImpl$BuilderBase.class...
processing android/support/v4/app/NotificationCompat$NotificationCompatImpl.class...
processing android/support/v4/app/NotificationCompat$NotificationVisibility.class...
processing android/support/v4/app/NotificationCompat$Style.class...
processing android/support/v4/app/NotificationCompat$WearableExtender.class...
processing android/support/v4/app/NotificationCompatApi20.class...
processing android/support/v4/app/NotificationCompatApi20$Builder.class...
processing android/support/v4/app/NotificationCompatApi21.class...
processing android/support/v4/app/NotificationCompatApi21$Builder.class...
processing android/support/v4/app/NotificationCompatApi24.class...
processing android/support/v4/app/NotificationCompatApi24$Builder.class...
processing android/support/v4/app/NotificationCompatApi26.class...
processing android/support/v4/app/NotificationCompatApi26$Builder.class...
processing android/support/v4/app/NotificationCompatBase.class...
processing android/support/v4/app/NotificationCompatBase$Action.class...
processing android/support/v4/app/NotificationCompatBase$Action$Factory.class...
processing android/support/v4/app/NotificationCompatBase$UnreadConversation.class...
processing android/support/v4/app/NotificationCompatBase$UnreadConversation$Factory.class...
processing android/support/v4/app/NotificationCompatExtras.class...
processing android/support/v4/app/NotificationCompatJellybean.class...
processing android/support/v4/app/NotificationCompatJellybean$Builder.class...
processing android/support/v4/app/NotificationCompatKitKat.class...
processing android/support/v4/app/NotificationCompatKitKat$Builder.class...
processing android/support/v4/app/NotificationCompatSideChannelService.class...
processing android/support/v4/app/NotificationCompatSideChannelService$NotificationSideChannelStub.class...
processing android/support/v4/app/NotificationManagerCompat.class...
processing android/support/v4/app/NotificationManagerCompat$C<message truncated>
```
#エラー原因
 いろいろ調べてみると、ライブラリーが重複しているから出ている可能性があるとのことだったので、「（プロジェクト名）/Assets/Plugins/Android」を見てみると、重複している.aarファイルが２組ありました。

![スクリーンショット 2019-02-12 10.23.41.png](https://qiita-image-store.s3.amazonaws.com/0/102567/d4df171e-fc22-4a67-d3e0-b163a34adc84.png)




- 「com.google.android.gms.**play-services-ads-base-15.0.1.aar**」と「**play-services-ads-base-15.0.1.aar**」

- 「com.google.android.gms.**play-services-basement-15.0.1.aar**」と「**play-services-basement-15.0.1.aar**」


#解決策
重複していた.aarファイルのそれぞれ片方（**play-services-ads-base-15.0.1.aar**と**play-services-basement-15.0.1.aar**）を消したらエラーが出なくなりました。


![スクリーンショット 2019-02-12 10.34.47.png](https://qiita-image-store.s3.amazonaws.com/0/102567/6b5f9512-c797-c384-3f59-0da82a50c411.png)

#最後に
エラーメッセージからどこに原因があるのかわかりづらいエラーだったので長時間原因探しに苦戦しました。
同じようなエラーが起きた方に少しでも役立てば幸いです。