Admob 和 GooglePlayGames 无法协同工作

Posted

技术标签:

【中文标题】Admob 和 GooglePlayGames 无法协同工作【英文标题】:Admob and GooglePlayGames not working together 【发布时间】:2019-02-14 01:58:37 【问题描述】:

我在 Unity android 游戏中使用以下插件:

1) Admob

2) Google Play 游戏

3) Unity IAP

我使用所有插件的最新版本。 Unity IAP 插件没有引起任何问题并且工作正常。如果没有 Admob,Google Play 游戏确实可以工作。当没有 Google Play 游戏时,Admob 也能正常工作。但是 Admob 和 GooglePlayGames 并没有合作。 尝试构建 Unity 项目时出现以下错误:

CommandInvokationFailure:无法将类转换为 dex 格式。 C:\Program Files\Android\Android Studio\jre\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:\Users\HP\AppData\Local\Android\Sdk\tools"

-Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar"

stderr[ 未捕获的翻译错误: java.lang.IllegalArgumentException:已添加: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient;未捕获 翻译错误:java.lang.IllegalArgumentException:已添加: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info; 未捕获的翻译错误:java.lang.IllegalArgumentException: 已经加入: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$zza; 未捕获的翻译错误:java.lang.IllegalArgumentException: 已添加:Lcom/google/android/gms/ads/identifier/zza;未捕获 翻译错误:java.lang.IllegalArgumentException:已添加: Lcom/google/android/gms/ads/identifier/zzb;未捕获的翻译 错误:java.lang.IllegalArgumentException:已添加: Lcom/google/android/gms/ads/identifier/zzc;未捕获的翻译 错误:java.lang.IllegalArgumentException:已添加: Lcom/google/android/gms/actions/ItemListIntents;未捕获的翻译 错误:java.lang.IllegalArgumentException:已添加: Lcom/google/android/gms/actions/NoteIntents;未捕获的翻译 错误:java.lang.IllegalArgumentException:已添加: Lcom/google/android/gms/actions/ReserveIntents;

意外的***异常:java.lang.RuntimeException: 翻译已中断 com.android.dx.command.dexer.Main.processAllFiles(Main.java:614) 在 com.android.dx.command.dexer.Main.runMonoDex(Main.java:310) 在 com.android.dx.command.dexer.Main.runDx(Main.java:288) 在 com.android.dx.command.dexer.Main.main(Main.java:244) 在 com.android.dx.command.Main.main(Main.java:95) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 SDKMain.main(SDKMain.java:130) 原因: java.lang.InterruptedException:错误太多 com.android.dx.command.dexer.Main.processAllFiles(Main.java:606) ... 9 更多] stdout[ 处理存档 C:\Users\Public\Documents\Unity Projects\Shapes\Temp\StagingArea\android-libraries\GoogleAIDL\libs.\classes.jar... 处理 com/android/vending/billing/BuildConfig.class... 处理 com/android/vending/billing/IInAppBillingService.class...处理 com/android/vending/billing/IInAppBillingService$Stub.class... 加工 com/android/vending/billing/IInAppBillingService$Stub$Proxy.class... 处理存档 C:\Users\Public\Documents\Unity Projects\Shapes\Temp\StagingArea\android-libraries\GooglePlay\libs.\classes.jar... 处理 com/unity/purchasing/googleplay/ActivityLauncher.class... 加工 com/unity/purchasing/googleplay/BillingServiceManager.class... 加工 com/unity/purchasing/googleplay/BillingServiceManager$1.class... 加工 com/unity/purchasing/googleplay/BillingServiceManager$1$1.class... 加工 com/unity/purchasing/googleplay/BillingServiceManager$1$2.class... 加工 com/unity/purchasing/googleplay/BillingServiceManager$2.class... 加工 com/unity/purchasing/googleplay/BillingServiceProcessor.class... 处理 com/unity/purchasing/googleplay/BuildConfig.class... 处理 com/unity/purchasing/googleplay/Consts.class... 处理 com/unity/purchasing/googleplay/Consts$PurchaseState.class... 加工 com/unity/purchasing/googleplay/Consts$ResponseCode.class... 加工 com/unity/purchasing/googleplay/GooglePlayBillingUnAvailableException.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$1.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$2.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$3.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$4.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$5.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$6.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$7.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$8.class... 加工 com/unity/purchasing/googleplay/GooglePlayPurchasing$Features.class... 处理 com/unity/purchasing/googleplay/IActivityLauncher.class... 加工 com/unity/purchasing/googleplay/IBillingServiceManager.class... 处理 com/unity/purchasing/googleplay/IabException.class... 处理 com/unity/purchasing/googleplay/IabHelper.class... 处理 com/unity/purchasing/googleplay/IabHelper$1.class... 处理 com/unity/purchasing/googleplay/IabHelper$2.class... 处理 com/unity/purchasing/googleplay/IabHelper$2$1.class... 处理 com/unity/purchasing/googleplay/IabHelper$3.class... 处理com/unity/purchasing/googleplay/IabHelper$3$1.class... 处理 com/unity/purchasing/googleplay/IabHelper$4.class... 处理 com/unity/purchasing/googleplay/IabHelper$5.class... 加工 com/unity/purchasing/googleplay/IabHelper$OnConsumeFinishedListener.class... 加工 com/unity/purchasing/googleplay/IabHelper$OnConsumeMultiFinishedListener.class... 加工 com/unity/purchasing/googleplay/IabHelper$OnIabPurchaseFinishedListener.class... 加工 com/unity/purchasing/googleplay/IabHelper$OnIabSetupFinishedListener.class... 加工 com/unity/purchasing/googleplay/IabHelper$QueryInventoryFinishedListener.class... 处理 com/unity/purchasing/googleplay/IabResult.class... 处理 com/unity/purchasing/googleplay/Inventory.class... 处理 com/unity/purchasing/googleplay/Purchase.class... 处理 com/unity/purchasing/googleplay/PurchaseActivity.class... 加工 com/unity/purchasing/googleplay/PurchaseFailedEvent.class... 处理 com/unity/purchasing/googleplay/SkuDetails.class... 处理 com/unity/purchasing/googleplay/VRPurchaseActivity.class... 处理存档 C:\Users\Public\Documents\Unity Projects\Shapes\Temp\StagingArea\android-libraries\admoblib-release\libs.\classes.jar... 处理 com/admob/plugin/AdmobHandler.class... 处理 com/admob/plugin/AdmobListenerProxy.class... 处理 com/admob/plugin/AdmobNativeAd.class... 处理 com/admob/plugin/AdmobNativeAd$1.class... 处理 com/admob/plugin/AdmobNativeAd$2.class... 处理 com/admob/plugin/AdmobNativeAd$3.class... 处理 com/admob/plugin/AdmobNativeAd$4.class... 处理 com/admob/plugin/AdmobUnityPlugin.class... 处理 com/admob/plugin/AdmobUnityPlugin$1.class... 处理 com/admob/plugin/BannerHandler.class... 处理 com/admob/plugin/BannerHandler$1.class... 处理 com/admob/plugin/BannerHandler$2.class... 处理 com/admob/plugin/BannerHandler$3.class... 处理 com/admob/plugin/BannerHandler$BannerPosition.class... 处理 com/admob/plugin/BuildConfig.class... 处理 com/admob/plugin/ClassicBannerHandler.class... 处理 com/admob/plugin/ClassicBannerHandler$1.class... 处理 com/admob/plugin/IAdmobListener.class...处理 com/admob/plugin/IAdmobNativeAdListener.class...处理 com/admob/plugin/InterstitialHandler.class...处理 com/admob/plugin/InterstitialHandler$1.class... 处理 com/admob/plugin/InterstitialHandler$2.class... 处理 com/admob/plugin/InterstitialHandler$3.class... 处理 com/admob/plugin/NativeBannerHandler.class... 处理 com/admob/plugin/NativeBannerHandler$1.class... 处理 com/admob/plugin/VideoHandler.class... 处理 com/admob/plugin/VideoHandler$1.class... 处理 com/admob/plugin/VideoHandler$2.class... 处理 com/admob/plugin/VideoHandler$3.class... 处理存档 C:\Users\Public\Documents\Unity Projects\Shapes\Temp\StagingArea\android-libraries\com.android.support.support-compat-25.2.0\libs.\classes.jar... 处理 android/support/compat/BuildConfig.class... 处理 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.class... 加工 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl.class... 加工 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoJellyBeanImpl.class... 加工 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoJellyBeanMr2Impl.class... 加工 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl.class... 加工 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl.class... 加工 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs.class... 加工 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatJellyBean.class... 加工 android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatJellyBeanMr2.class... 处理 android/support/v4/animation/AnimatorCompatHelper.class... 加工 android/support/v4/animation/AnimatorListenerCompat.class... 处理 android/support/v4/animation/AnimatorProvider.class... 加工 android/support/v4/animation/AnimatorUpdateListenerCompat.class... 加工 android/support/v4/animation/GingerbreadAnimatorCompatProvider.class... 加工 android/support/v4/animation/GingerbreadAnimatorCompatProvider$GingerbreadFloatValueAnimator.class... 加工 android/support/v4/animation/GingerbreadAnimatorCompatProvider$GingerbreadFloatValueAnimator$1.class... 加工 android/support/v4/animation/HoneycombMr1AnimatorCompatProvider.class... 加工 android/support/v4/animation/HoneycombMr1AnimatorCompatProvider$AnimatorListenerCompatWrapper.class... 加工 android/support/v4/animation/HoneycombMr1AnimatorCompatProvider$HoneycombValueAnimatorCompat.class... 加工 android/support/v4/animation/HoneycombMr1AnimatorCompatProvider$HoneycombValueAnimatorCompat$1.class... 处理 android/support/v4/animation/ValueAnimatorCompat.class... 处理android/support/v4/app/ActivityCompat.class...处理 android/support/v4/app/ActivityCompat$1.class...处理 android/support/v4/app/ActivityCompat$OnRequestPermissionsResultCallback.class... 加工 android/support/v4/app/ActivityCompat$SharedElementCallback21Impl.class... 加工 android/support/v4/app/ActivityCompat$SharedElementCallback23Impl.class... 加工 android/support/v4/app/ActivityCompat$SharedElementCallback23Impl$1.class... 处理 android/support/v4/app/ActivityCompatApi21.class... 加工 android/support/v4/app/ActivityCompatApi21$SharedElementCallback21.class... 加工 android/support/v4/app/ActivityCompatApi21$SharedElementCallbackImpl.class... 处理android/support/v4/app/ActivityCompatApi22.class... 处理 android/support/v4/app/ActivityCompatApi23.class... 加工 android/support/v4/app/ActivityCompatApi23$OnSharedElementsReadyListenerBridge.class... 加工 android/support/v4/app/ActivityCompatApi23$RequestPermissionsRequestCodeValidator.class... 加工 android/support/v4/app/ActivityCompatApi23$SharedElementCallback23.class... 加工 android/support/v4/app/ActivityCompatApi23$SharedElementCallbackImpl.class... 加工 android/support/v4/app/ActivityCompatApi23$SharedElementCallbackImpl$1.class... 处理 android/support/v4/app/ActivityCompatHoneycomb.class... 处理android/support/v4/app/ActivityCompatJB.class...处理 android/support/v4/app/ActivityManagerCompat.class...处理 android/support/v4/app/ActivityManagerCompatKitKat.class...处理 android/support/v4/app/ActivityOptionsCompat.class...处理 android/support/v4/app/ActivityOptionsCompat$ActivityOptionsImpl21.class... 加工 android/support/v4/app/ActivityOptionsCompat$ActivityOptionsImpl23.class... 加工 android/support/v4/app/ActivityOptionsCompat$ActivityOptionsImpl24.class... 加工 android/support/v4/app/ActivityOptionsCompat$ActivityOptionsImplJB.class... 处理 android/support/v4/app/ActivityOptionsCompat21.class... 处理 android/support/v4/app/ActivityOptionsCompat23.class... 处理 android/support/v4/app/ActivityOptionsCompat24.class... 处理 android/support/v4/app/ActivityOptionsCompatJB.class... 处理 android/support/v4/app/AppOpsManagerCompat.class... 加工 android/support/v4/app/AppOpsManagerCompat$AppOpsManager23.class... 加工 android/support/v4/app/AppOpsManagerCompat$AppOpsManagerImpl.class... 处理 android/support/v4/app/AppOpsManagerCompat23.class... 处理android/support/v4/app/BundleCompat.class...处理 android/support/v4/app/BundleCompatGingerbread.class...处理 android/support/v4/app/BundleCompatJellybeanMR2.class...处理 android/support/v4/app/BundleUtil.class...处理 android/support/v4/app/INotificationSideChannel.class...处理 android/support/v4/app/INotificationSideChannel$Stub.class... 加工 android/support/v4/app/INotificationSideChannel$Stub$Proxy.class... 加工 android/support/v4/app/NotificationBuilderWithActions.class... 加工 android/support/v4/app/NotificationBuilderWithBuilderAccessor.class... 处理 android/support/v4/app/NotificationCompat.class... 处理 android/support/v4/app/NotificationCompat$Action.class... 处理 android/support/v4/app/NotificationCompat$Action$1.class... 加工 android/support/v4/app/NotificationCompat$Action$Builder.class... 加工 android/support/v4/app/NotificationCompat$Action$Extender.class... 加工 android/support/v4/app/NotificationCompat$Action$WearableExtender.class... 加工 android/support/v4/app/NotificationCompat$BigPictureStyle.class... 加工 android/support/v4/app/NotificationCompat$BigTextStyle.class... 处理 android/support/v4/app/NotificationCompat$Builder.class... 加工 android/support/v4/app/NotificationCompat$BuilderExtender.class... 加工 android/support/v4/app/NotificationCompat$CarExtender.class... 加工 android/support/v4/app/NotificationCompat$CarExtender$UnreadConversation.class... 加工 android/support/v4/app/NotificationCompat$CarExtender$UnreadConversation$1.class... 加工 android/support/v4/app/NotificationCompat$CarExtender$UnreadConversation$Builder.class... 处理 android/support/v4/app/NotificationCompat$Extender.class... 加工 android/support/v4/app/NotificationCompat$InboxStyle.class... 加工 android/support/v4/app/NotificationCompat$MessagingStyle.class... 加工 android/support/v4/app/NotificationCompat$MessagingStyle$Message.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImpl.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImplApi20.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImplApi21.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImplApi24.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImplBase.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImplHoneycomb.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImplIceCreamSandwich.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImplJellybean.class... 加工 android/support/v4/app/NotificationCompat$NotificationCompatImplKitKat.class... 处理 android/support/v4/app/NotificationCompat$Style.class... 加工 android/support/v4/app/NotificationCompat$WearableExtender.class... 处理android/support/v4/app/NotificationCompatApi20.class... 加工 android/support/v4/app/NotificationCompatApi20$Builder.class... 处理android/support/v4/app/NotificationCompatApi21.class... 加工 android/support/v4/app/NotificationCompatApi21$Builder.class... 处理 android/support/v4/app/NotificationCompatApi23.class... 处理 android/support/v4/app/NotificationCompatApi24.class... 处理android/support/v4/app/NotificationCompatApi24$Bu

我在 *** 和 GitHub 上看到过类似的问题。但是,那里提到的解决方案对我没有用。

有人可以帮我解决这个问题吗?提前致谢!

【问题讨论】:

【参考方案1】:

显示此错误是因为 DEX 工具 在运行在 .dex 文件中编译的 Android 程序时出现故障(这些程序又被压缩到设备上的单个 .apk 文件中) .这个工具由 Unity 作为 Android 进程的一部分执行。当有多个库(多个相同的类)被添加到 APK 时会发生错误。

stderr[ 未捕获的翻译错误: java.lang.IllegalArgumentException:已添加: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient;未捕获 翻译错误:java.lang.IllegalArgumentException:已添加:

因此,您只需删除重复的库,保留最新版本并使用播放解析器将它们更新到新版本。

请参阅 Google Mobile Ads SDK for Unity 的完整版 documentation。

您还可以查看video tutorial,了解 Unity 中 Google Play 游戏服务和 Admob 插件的最佳实践。

【讨论】:

我没有看到任何重复的库。另外,我使用的是最新版本。你分享的视频中的那个人会说一些外语。因此,我什么都看不懂。 PS:没有 GooglePlayGames 时 Admob 工作正常,反之亦然。

以上是关于Admob 和 GooglePlayGames 无法协同工作的主要内容,如果未能解决你的问题,请参考以下文章

Admob bannerView请求错误:无广告显示

Unity GooglePlayGames LoadScores 始终不返回任何内容

我可以在同一活动中显示 admob 原生广告和 admob 横幅广告吗?

Admob 和 facebook 中介 IOS

Admob 可用性和收费

AdMob帐户迁移和AdSense帐户