Unable to convert 类 into dex format build error in Unity 5.3.4f1, when Google Play games plugin & Facebook plugins added into the project

Unable to convert classes into dex format build error in Unity 5.3.4f1, when Google Play games plugin & Facebook plugins are added into the project

在我的游戏中,导入 Google 玩游戏插件和 Facebook 插件后,我无法构建我的 Unity 项目。它给出了构建错误,无法将 类 转换为 dex 格式。 Unity 版本为 5.3.4f1。 google玩游戏插件版本为0.9.32。 Facebook 插件版本为 7.5.0。我得到的错误日志是这样的:

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:\Program Files\Java\jdk1.8.0_31\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="E:/Adt/adt-bundle-windows-x86_64-20140702/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/BuildConfig;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoJellyBeanMr2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorCompatHelper;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActionBarDrawerToggle;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActionBarDrawerToggle;

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
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:483)
at SDKMain.main(SDKMain.java:129)

Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600)
... 9 more
]
stdout[
processing archive F:\User\path1\path2\path3\Temp\StagingArea\android-libraries\MainLibProj\libs\.\play-games-plugin-support.jar...
ignored resource META-INF/
ignored resource META-INF/MANIFEST.MF
ignored resource com/
ignored resource com/google/
ignored resource com/google/games/
ignored resource com/google/games/bridge/
processing com/google/games/bridge/BuildConfig.class...
processing com/google/games/bridge/NativeBridgeActivity.class...
processing com/google/games/bridge/TokenFragment.class...
processing com/google/games/bridge/TokenFragment.class...
processing com/google/games/bridge/TokenFragment.class...
processing com/google/games/bridge/TokenFragment.class...
processing com/google/games/bridge/TokenFragment$TokenRequest.class...
processing com/google/games/bridge/TokenPendingResult.class...
processing com/google/games/bridge/TokenResult.class...
processing archive F:\User\path1\path2\path3\Temp\StagingArea\android-libraries\cardview-v7-23.2.1\bin\classes.jar...
processing android/support/v7/cardview/BuildConfig.class...
processing android/support/v7/widget/CardView.class...
processing android/support/v7/widget/CardViewApi21.class...
processing android/support/v7/widget/CardViewDelegate.class...
processing android/support/v7/widget/CardViewEclairMr1.class...
processing android/support/v7/widget/CardViewEclairMr1.class...
processing android/support/v7/widget/CardViewImpl.class...
processing android/support/v7/widget/CardViewJellybeanMr1.class...
processing android/support/v7/widget/CardViewJellybeanMr1.class...
processing android/support/v7/widget/RoundRectDrawable.class...
processing android/support/v7/widget/RoundRectDrawableWithShadow.class...
processing android/support/v7/widget/RoundRectDrawableWithShadow$RoundRectHelper.class...
processing archive F:\User\path1\path2\path3\Temp\StagingArea\android-libraries\facebook-android-sdk-4.11.0\bin\classes.jar...
ignored resource META-INF/
ignored resource META-INF/MANIFEST.MF
ignored resource android/
ignored resource android/support/
ignored resource android/support/v7/
ignored resource android/support/v7/cardview/
ignored resource com/
ignored resource com/facebook/
processing com/facebook/AccessToken.class...
processing com/facebook/AccessToken.class...
processing com/facebook/AccessToken.class...
processing com/facebook/AccessToken$AccessTokenCreationCallback.class...
processing com/facebook/AccessToken$AccessTokenRefreshCallback.class...
processing com/facebook/AccessTokenCache.class...
processing com/facebook/AccessTokenCache$SharedPreferencesTokenCachingStrategyFactory.class...
processing com/facebook/AccessTokenManager.class...
processing com/facebook/AccessTokenManager.class...
processing com/facebook/AccessTokenManager.class...
processing com/facebook/AccessTokenManager.class...
processing com/facebook/AccessTokenManager.class...
processing com/facebook/AccessTokenManager$RefreshResult.class...
processing com/facebook/AccessTokenSource.class...
processing com/facebook/AccessTokenTracker.class...
processing com/facebook/AccessTokenTracker.class...
processing com/facebook/AccessTokenTracker$CurrentAccessTokenBroadcastReceiver.class...
processing com/facebook/BuildConfig.class...
processing com/facebook/CallbackManager.class...
processing com/facebook/CallbackManager$Factory.class...
processing com/facebook/CustomTabActivity.class...
processing com/facebook/FacebookActivity.class...
processing com/facebook/FacebookAuthorizationException.class...
processing com/facebook/FacebookBroadcastReceiver.class...
processing com/facebook/FacebookButtonBase.class...
processing com/facebook/FacebookButtonBase.class...
processing com/facebook/FacebookCallback.class...
processing com/facebook/FacebookContentProvider.class...
processing com/facebook/FacebookDialog.class...
processing com/facebook/FacebookDialogException.class...
processing com/facebook/FacebookException.class...
processing com/facebook/FacebookGraphResponseException.class...
processing com/facebook/FacebookOperationCanceledException.class...
processing com/facebook/FacebookRequestError.class...
processing com/facebook/FacebookRequestError.class...
processing com/facebook/FacebookRequestError$Category.class...
processing com/facebook/FacebookRequestError$Range.class...
processing com/facebook/FacebookSdk.class...
processing com/facebook/FacebookSdk.class...
processing com/facebook/FacebookSdk.class...
processing com/facebook/FacebookSdk.class...
processing com/facebook/FacebookSdk.class...
processing com/facebook/FacebookSdk$InitializeCallback.class...
processing com/facebook/FacebookSdkNotInitializedException.class...
processing com/facebook/FacebookSdkVersion.class...
processing com/facebook/FacebookServiceException.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest$Attachment.class...
processing com/facebook/GraphRequest$Callback.class...
processing com/facebook/GraphRequest$GraphJSONArrayCallback.class...
processing com/facebook/GraphRequest$GraphJSONObjectCallback.class...
processing com/facebook/GraphRequest$KeyValueSerializer.class...
processing com/facebook/GraphRequest$OnProgressCallback.class...
processing com/facebook/GraphRequest$ParcelableResourceWithMimeType.class...
processing com/facebook/GraphRequest$ParcelableResourceWithMimeType.class...
processing com/facebook/GraphRequest$Serializer.class...
processing com/facebook/GraphRequestAsyncTask.class...
processing com/facebook/GraphRequestBatch.class...
processing com/facebook/GraphRequestBatch$Callback.class...
processing com/facebook/GraphRequestBatch$OnProgressCallback.class...
processing com/facebook/GraphResponse.class...
processing com/facebook/GraphResponse$PagingDirection.class...
processing com/facebook/HttpMethod.class...
processing com/facebook/LegacyTokenHelper.class...
processing com/facebook/LoggingBehavior.class...
processing com/facebook/Profile.class...
processing com/facebook/Profile.class...
processing com/facebook/Profile.class...
processing com/facebook/ProfileCache.class...
processing com/facebook/ProfileManager.class...
processing com/facebook/ProfileTracker.class...
processing com/facebook/ProfileTracker.class...
processing com/facebook/ProfileTracker$ProfileBroadcastReceiver.class...
processing com/facebook/ProgressNoopOutputStream.class...
processing com/facebook/ProgressOutputStream.class...
processing com/facebook/ProgressOutputStream.class...
processing com/facebook/RequestOutputStream.class...
processing com/facebook/RequestProgress.class...
processing com/facebook/RequestProgress.class...
processing com/facebook/TestUserManager.class...
processing com/facebook/TestUserManager$Mode.class...
ignored resource com/facebook/appevents/
processing com/facebook/appevents/AppEventsConstants.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger$AccessTokenAppIdPair.class...
processing com/facebook/appevents/AppEventsLogger$AccessTokenAppIdPair$SerializationProxyV1.class...
processing com/facebook/appevents/AppEventsLogger$AppEvent.class...
processing com/facebook/appevents/AppEventsLogger$AppEvent$SerializationProxyV1.class...
processing com/facebook/appevents/AppEventsLogger$FlushBehavior.class...
processing com/facebook/appevents/AppEventsLogger$FlushReason.class...
processing com/facebook/appevents/AppEventsLogger$FlushResult.class...
processing com/facebook/appevents/AppEventsLogger$FlushStatistics.class...
processing com/facebook/appevents/AppEventsLogger$PersistedAppSessionInfo.class...
processing com/facebook/appevents/AppEventsLogger$PersistedAppSessionInfo.class...
processing com/facebook/appevents/AppEventsLogger$PersistedEvents.class...
processing com/facebook/appevents/AppEventsLogger$SessionEventsState.class...
processing com/facebook/appevents/FacebookTimeSpentData.class...
processing com/facebook/appevents/FacebookTimeSpentData.class...
processing com/facebook/appevents/FacebookTimeSpentData$SerializationProxyV1.class...
processing com/facebook/appevents/FacebookTimeSpentData$SerializationProxyV2.class...
ignored resource com/facebook/appevents/internal/
processing com/facebook/appevents/internal/ActivityLifecycleTracker.class...
processing com/facebook/appevents/internal/ActivityLifecycleTracker.class...
processing com/facebook/appevents/internal/ActivityLifecycleTracker.class...
processing com/facebook/appevents/internal/ActivityLifecycleTracker.class...
processing  com/facebook/appevents/internal/ActivityLifecycleTracker.class...
processing com/facebook/appevents/internal/ActivityLifecycleTracker.class...
processing com/facebook/appevents/internal/Constants.class...
processing com/facebook/appevents/internal/SessionInfo.class...
processing com/facebook/appevents/internal/SessionLogger.class...
processing com/facebook/appevents/internal/SourceApplicationInfo.class...
processing com/facebook/appevents/internal/SourceApplicationInfo.class...
processing com/facebook/appevents/internal/SourceApplicationInfo$Factory.class...
ignored resource com/facebook/applinks/
processing com/facebook/applinks/AppLinkData.class...
processing com/facebook/applinks/AppLinkData.class...
processing com/facebook/applinks/AppLinkData$CompletionHandler.class...
processing com/facebook/applinks/FacebookAppLinkResolver.class...
processing com/facebook/applinks/FacebookAppLinkResolver.class...
processing com/facebook/applinks/FacebookAppLinkResolver.class...
ignored resource com/facebook/internal/
processing com/facebook/internal/AnalyticsEvents.class...
processing com/facebook/internal/AppCall.class...
processing com/facebook/internal/AppEventsLoggerUtility.class...
processing com/facebook/internal/AppEventsLoggerUtility.class...
processing com/facebook/internal/AppEventsLoggerUtility$GraphAPIActivityType.class...
processing com/facebook/internal/AttributionIdentifiers.class...
processing com/facebook/internal/AttributionIdentifiers.class...
processing com/facebook/internal/AttributionIdentifiers$GoogleAdInfo.class...
processing com/facebook/internal/AttributionIdentifiers$GoogleAdServiceConnection.class...
processing com/facebook/internal/BoltsMeasurementEventListener.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter$Setter.class...
processing com/facebook/internal/CallbackManagerImpl.class...
processing com/facebook/internal/CallbackManagerImpl$Callback.class...
processing com/facebook/internal/CallbackManagerImpl$RequestCodeOffset.class...
processing com/facebook/internal/CollectionMapper.class...
processing com/facebook/internal/CollectionMapper.class...
processing com/facebook/internal/CollectionMapper.class...
processing com/facebook/internal/CollectionMapper$Collection.class...
processing com/facebook/internal/CollectionMapper$OnErrorListener.class...
processing com/facebook/internal/CollectionMapper$OnMapValueCompleteListener.class...
processing com/facebook/internal/CollectionMapper$OnMapperCompleteListener.class...
processing com/facebook/internal/CollectionMapper$ValueMapper.class...
processing com/facebook/internal/CustomTab.class...
processing com/facebook/internal/DialogFeature.class...
processing com/facebook/internal/DialogPresenter.class...
processing com/facebook/internal/DialogPresenter$ParameterProvider.class...
processing com/facebook/internal/FacebookDialogBase.class...
processing com/facebook/internal/FacebookDialogBase$ModeHandler.class...
processing com/facebook/internal/FacebookDialogFragment.class...
processing com/facebook/internal/FacebookDialogFragment.class...
processing com/facebook/internal/FacebookDialogFragment.class...
processing com/facebook/internal/FacebookRequestErrorClassification.class...
processing com/facebook/internal/FacebookRequestErrorClassification.class...
processing com/facebook/internal/FacebookRequestErrorClassification.class...
processing com/facebook/internal/FacebookRequestErrorClassification.class...
processing com/facebook/internal/FacebookWebFallbackDialog.class...
processing com/facebook/internal/FacebookWebFallbackDialog.class...
processing com/facebook/internal/FileLruCache.class...
processing com/facebook/internal/FileLruCache.class...
processing com/facebook/internal/FileLruCache.class...
processing com/facebook/interna<message truncated>

我猜是因为 Support-v4 aar 文件。项目中有两份Support-v4 aar 文件,当时我添加了google play games plugin 和facebook sdk plugin。但是当我尝试删除任何一个 aar 文件时,项目构建成功,但插件根本无法工作。那么有什么办法可以解决这个问题。?提前致谢。

转到 A​​ssets->FacebookSDK->Plugins->Android->libs 然后 delete android-支持-v4.jar。那里有冲突,因为它包含来自另一个 jar 或 aar 文件的 class。

这个问题也已解决 。如果那没有解决您的问题,请创建一个空项目,导入 facebook 和 google 插件。然后压缩并上传项目。

我没有找到任何重复的插件。升级到 JDK8 并在 Unity 首选项中指向它为我解决了这个问题。

我遇到了类似的问题。解决这个问题的一般方法是:

  1. 在 Windows Explorer 中,导航到 [project]\Assets。
  2. 要列出所有 jar 和 aar 文件,请在资源管理器右上角的搜索框中输入 *.?ar
  3. 右键单击任意位置以查看详细信息,然后按名称排序。
  4. 检查具有相同或相似名称的文件。通常这些是相同的文件,可能是不同的版本。
  5. 删除旧版本的文件。

完成!

就我而言,冲突错误来自 Google 移动广告和 Facebook SDK。我需要删除两个文件:

Assets\FacebookSDK\Plugins\Android\libs\support-annotations-23.4.0.jar(已删除)

Assets\FacebookSDK\Plugins\Android\libs\support-v4-23.4.0.aar(已删除)

Assets\Plugins\support-annotations-24.0.0.jar

Assets\Plugins\support-v4-24.0.0.aar

解决这个问题:

  1. 在 "support"
  2. 上搜索主资产文件夹
  3. 检查双 support-annotations 并支持-V4
  4. 寻找旧版本
  5. 取消选中 "Android" 并单击 "Apply"

完成。

我遇到了同样的问题,通过删除 Google Play 文件夹中旧版本的重复文件解决了这个问题。您可以在 image 中看到它。我想它会对你有所帮助。