在我的Unity游戏中,导入Admob Unity插件后,我无法构建我的项目。它给出了构建错误,无法将类转换为dex格式,Unity版本为5.3.5f1。我得到的错误日志是:
> <p> Error building Player: CommandInvokationFailure: Unable to convert
> classes into dex format. See the Console for details. C:\Program
> Files\Java\jdk1.8.0_74\bin\java.exe -Xmx2048M
> -Dcom.android.sdkmanager.toolsdir="C:/Users/Rajan/AppData/Local/Android/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:
> Lcom/unity3d/ads/android/BuildConfig; Uncaught translation error:
> java.lang.IllegalArgumentException: already added:
> Lcom/unity3d/ads/android/IUnityAdsListener; Uncaught translation
> error: java.lang.IllegalArgumentException: already added:
> Lcom/unity3d/ads/android/UnityAds; Uncaught translation error:
> java.lang.IllegalArgumentException: already added:
> Lcom/unity3d/ads/android/UnityAds$1; Uncaught translation error:
> java.lang.IllegalArgumentException: already added:
> Lcom/unity3d/ads/android/UnityAds$2; Uncaught translation error:
> java.lang.IllegalArgumentException: already added:
> Lcom/unity3d/ads/android/UnityAds$3; Uncaught translation error:
> java.lang.IllegalArgumentException: already added:
> Lcom/unity3d/ads/android/UnityAdsDeviceLog; Uncaught translation
> error: java.lang.IllegalArgumentException: already added:
> Lcom/unity3d/ads/android/UnityAdsDeviceLog$1; Uncaught translation
> error: java.lang.IllegalArgumentException: already added:
> Lcom/unity3d/ads/android/UnityAdsDeviceLog$UnityAdsLogLevel;
>
> 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:498) 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:\Unity Projects\Car Racing
> Game\Temp\StagingArea\android-libraries\unityads-release\libs\.\classes.jar...
> ignored resource META-INF/ ignored resource META-INF/MANIFEST.MF
> ignored resource com/ ignored resource com/unity3d/ ignored resource
> com/unity3d/ads/ ignored resource com/unity3d/ads/android/ processing
> com/unity3d/ads/android/BuildConfig.class... processing
> com/unity3d/ads/android/IUnityAdsListener.class... processing
> com/unity3d/ads/android/UnityAds.class... processing
> com/unity3d/ads/android/UnityAds$1.class... processing
> com/unity3d/ads/android/UnityAds$2.class... processing
> com/unity3d/ads/android/UnityAds$3.class... processing
> com/unity3d/ads/android/UnityAdsDeviceLog.class... processing
> com/unity3d/ads/android/UnityAdsDeviceLog$1.class... processing
> com/unity3d/ads/android/UnityAdsDeviceLog$UnityAdsLogLevel.class...
> processing
> com/unity3d/ads/android/UnityAdsDeviceLog$UnityAdsShowMsg.class...
> processing com/unity3d/ads/android/UnityAdsDeviceLogEntry.class...
> processing com/unity3d/ads/android/UnityAdsDeviceLogLevel.class...
> processing com/unity3d/ads/android/UnityAdsUtils.class... ignored
> resource com/unity3d/ads/android/cache/ processing
> com/unity3d/ads/android/cache/UnityAdsCache.class... processing
> com/unity3d/ads/android/cache/UnityAdsCache$1.class... processing
> com/unity3d/ads/android/cache/UnityAdsCacheThread.class... processing
> com/unity3d/ads/android/cache/UnityAdsCacheThreadHandler.class...
> ignored resource com/unity3d/ads/android/campaign/ processing
> com/unity3d/ads/android/campaign/UnityAdsCampaign.class... processing
> com/unity3d/ads/android/campaign/UnityAdsCampaign$UnityAdsCampaignStatus.class...
> ignored resource com/unity3d/ads/android/data/ processing
> com/unity3d/ads/android/data/UnityAdsAdvertisingId.class... processing
> com/unity3d/ads/android/data/UnityAdsAdvertisingId$1.class...
> processing
> com/unity3d/ads/android/data/UnityAdsAdvertisingId$GoogleAdvertisingInfo.class...
> processing
> com/unity3d/ads/android/data/UnityAdsAdvertisingId$GoogleAdvertisingInfo$GoogleAdvertisingInfoBinder.class...
> processing
> com/unity3d/ads/android/data/UnityAdsAdvertisingId$GoogleAdvertisingInfo$GoogleAdvertisingInfoBinder$GoogleAdvertisingInfoImplementation.class...
> processing
> com/unity3d/ads/android/data/UnityAdsAdvertisingId$GoogleAdvertisingServiceConnection.class...
> processing com/unity3d/ads/android/data/UnityAdsDevice.class...
> ignored resource com/unity3d/ads/android/item/ processing
> com/unity3d/ads/android/item/UnityAdsRewardItem.class... processing
> com/unity3d/ads/android/item/UnityAdsRewardItemManager.class...
> ignored resource com/unity3d/ads/android/properties/ processing
> com/unity3d/ads/android/properties/UnityAdsConstants.class...
> processing
> com/unity3d/ads/android/properties/UnityAdsProperties.class... ignored
> resource com/unity3d/ads/android/unity3d/ processing
> com/unity3d/ads/android/unity3d/UnityAdsUnityEngineWrapper.class...
> processing
> com/unity3d/ads/android/unity3d/UnityAdsUnityEngineWrapper$1.class...
> processing
> com/unity3d/ads/android/unity3d/UnityAdsUnityWrapper.class...
> processing
> com/unity3d/ads/android/unity3d/UnityAdsUnityWrapper$1.class...
> ignored resource com/unity3d/ads/android/video/ processing
> com/unity3d/ads/android/video/IUnityAdsVideoPlayerListener.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPausedView.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$1.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$2.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$3.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$4.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$5.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$6.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$7.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$8.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$9.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$VideoStateChecker.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$VideoStateChecker$1.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$VideoStateChecker$2.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$VideoStateChecker$3.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$VideoStateChecker$4.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$VideoStateChecker$5.class...
> processing
> com/unity3d/ads/android/video/UnityAdsVideoPlayView$VideoStateChecker$6.class...
> processing com/unity3d/ads/android/video/UnityAdsVideoView.class...
> ignored resource com/unity3d/ads/android/view/ processing
> com/unity3d/ads/android/view/UnityAdsFullscreenActivity.class...
> processing
> com/unity3d/ads/android/view/UnityAdsFullscreenActivity$1.class...
> processing
> com/unity3d/ads/android/view/UnityAdsFullscreenActivity$UnityAdsPlayVideoRunner.class...
> processing com/unity3d/ads/android/view/UnityAdsMainView.class...
> processing com/unity3d/ads/android/view/UnityAdsMainView$1.class...
> processing com/unity3d/ads/android/view/UnityAdsMainView$2.class...
> processing com/unity3d/ads/android/view/UnityAdsMainView$2$1.class...
> processing com/unity3d/ads/android/view/UnityAdsMainView$3.class...
> processing com/unity3d/ads/android/view/UnityAdsMainView$4.class...
> processing
> com/unity3d/ads/android/view/UnityAdsMainView$UnityAdsMainViewState.class...
> processing
> com/unity3d/ads/android/view/UnityAdsMuteVideoButton.class...
> processing
> com/unity3d/ads/android/view/UnityAdsMuteVideoButton$1.class...
> processing
> com/unity3d/ads/android/view/UnityAdsMuteVideoButton$UnityAdsMuteVideoButtonState.class...
> processing com/unity3d/ads/android/view/UnityAdsViewUtils.class...
> ignored resource com/unity3d/ads/android/webapp/ processing
> com/unity3d/ads/android/webapp/IUnityAdsWebBridgeListener.class...
> processing
> com/unity3d/ads/android/webapp/IUnityAdsWebDataListener.class...
> processing
> com/unity3d/ads/android/webapp/IUnityAdsWebViewListener.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebBridge.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebBridge$1.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebBridge$UnityAdsWebEvent.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebData.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebData$1.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebData$2.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebData$3.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebData$4.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebData$5.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebData$6.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebData$UnityAdsCancelUrlLoaderRunner.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebData$UnityAdsRequestType.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebData$UnityAdsUrlLoader.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebData$UnityAdsUrlLoaderCreator.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebData$UnityAdsVideoPosition.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebView.class...
> processing com/unity3d/ads/android/webapp/UnityAdsWebView$1.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebView$UnityAdsJavascriptRunner.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebView$UnityAdsViewChromeClient.class...
> processing
> com/unity3d/ads/android/webapp/UnityAdsWebView$UnityAdsViewClient.class...
> ignored resource com/unity3d/ads/android/zone/ processing
> com/unity3d/ads/android/zone/UnityAdsIncentivizedZone.class...
> processing com/unity3d/ads/android/zone/UnityAdsZone.class...
> processing com/unity3d/ads/android/zone/UnityAdsZoneManager.class...
> processing bin\classes\.\com\admob\demo\R.class... processing
> bin\classes\.\com\admob\demo\R$attr.class... processing
> bin\classes\.\com\admob\demo\R$drawable.class... processing
> bin\classes\.\com\admob\demo\R$id.class... processing
> bin\classes\.\com\admob\demo\R$layout.class... processing
> bin\classes\.\com\admob\demo\R$string.class... processing
> bin\classes\.\com\admob\demo\R$style.class... processing
> bin\classes\.\com\unity3d\ads\android\R.class... processing
> bin\classes\.\com\unity3d\ads\android\R$attr.class... processing
> bin\classes\.\com\unity3d\ads\android\R$drawable.class... processing
> bin\classes\.\com\unity3d\ads\android\R$id.class... processing
> bin\classes\.\com\unity3d\ads\android\R$layout.class... processing
> bin\classes\.\com\unity3d\ads\android\R$string.class... processing
> bin\classes\.\com\unity3d\ads\android\R$style.class... processing
> archive bin\classes.jar... processing
> bitter/jnibridge/JNIBridge.class... processing
> bitter/jnibridge/JNIBridge$a.class... processing
> com/unity3d/player/NativeLoader.class... processing
> com/unity3d/player/ReflectionHelper.class... processing
> com/unity3d/player/ReflectionHelper$1.class... processing
> com/unity3d/player/ReflectionHelper$a.class... processing
> com/unity3d/player/UnityPlayer.class... processing
> com/unity3d/player/UnityPlayer$1.class... processing
> com/unity3d/player/UnityPlayer$10.class... processing
> com/unity3d/player/UnityPlayer$11.class... processing
> com/unity3d/player/UnityPlayer$12.class... processing
> com/unity3d/player/UnityPlayer$13.class... processing
> com/unity3d/player/UnityPlayer$14.class... processing
> com/unity3d/player/UnityPlayer$15.class... processing
> com/unity3d/player/UnityPlayer$15$1.class... processing
> com/unity3d/player/UnityPlayer$16.class... processing
> com/unity3d/player/UnityPlayer$17.class... processing
> com/unity3d/player/UnityPlayer$18.class... processing
> com/unity3d/player/UnityPlayer$19.class... processing
> com/unity3d/player/UnityPlayer$2.class... processing
> com/unity3d/player/UnityPlayer$20.class... processing
> com/unity3d/player/UnityPlayer$3.class... processing
> com/unity3d/player/UnityPlayer$4.class... processing
> com/unity3d/player/UnityPlayer$5.class... processing
> com/unity3d/player/UnityPlayer$6.class... processing
> com/unity3d/player/UnityPlayer$7.class... processing
> com/unity3d/player/UnityPlayer$8.class... processing
> com/unity3d/player/UnityPlayer$9.class... processing
> com/unity3d/player/UnityPlayer$a.class... processing
> com/unity3d/player/UnityPlayer$b.class... processing
> com/unity3d/player/UnityPlayer$c.class... processing
> com/unity3d/player/UnityPlayerActivity.class... processing
> com/unity3d/player/UnityPlayerNativeActivity.class... processing
> com/unity3d/player/UnityPlayerProxyActivity.class... processing
> com/unity3d/player/UnityWebRequest.class... processing
> com/unity3d/player/WWW.class... processing
> com/unity3d/player/a.class... processing
> com/unity3d/player/a$1.class... processing
> com/unity3d/player/a$2.class... processing
> com/unity3d/player/a$a.class... processing
> com/unity3d/player/b.class... processing
> com/unity3d/player/b$1.class... processing
> com/unity3d/player/b$2.class... processing
> com/unity3d/player/c.class... processing com/unity3d/player/d.class...
> processing com/unity3d/player/d$1.class... processing
> com/unity3d/player/d$2.class... processing
> com/unity3d/player/e.class... processing com/unity3d/player/f.class...
> processing com/unity3d/player/g.class... processing
> com/unity3d/player/h.class... processing com/unity3d/player/i.class...
> processing com/unity3d/player/j.class... processing
> com/unity3d/player/k.class... processing
> com/unity3d/player/k$1.class... processing
> com/unity3d/player/k$2.class... processing
> com/unity3d/player/k$2$1.class... processing
> com/unity3d/player/k$2$1$1.class... processing
> com/unity3d/player/l.class... processing
> com/unity3d/player/l$1.class... processing
> com/unity3d/player/m.class... processing com/unity3d/player/n.class...
> processing com/unity3d/player/n$1.class... processing
> com/unity3d/player/o.class... processing com/unity3d/player/p.class...
> processing com/unity3d/player/p$1.class... processing
> com/unity3d/player/q.class... processing com/unity3d/player/r.class...
> processing com/unity3d/player/s.class... processing
> com/unity3d/player/s$1.class... processing
> com/unity3d/player/s$2.class... processing
> com/unity3d/player/s$3.class... processing
> com/unity3d/player/t.class... processing com/unity3d/player/u.class...
> processing com/unity3d/player/v.class... processing
> com/unity3d/player/w.class... processing
> com/unity3d/player/w$1.class... processing
> org/fmod/FMODAudioDevice.class... processing org/fmod/a.class...
> processing archive plugins\.\admobunityplugin.jar... ignored resource
> META-INF/MANIFEST.MF processing
> com/admob/plugin/AdmobUnityPlugin.class... processing
> com/admob/plugin/IAdmobListener.class... processing
> com/admob/plugin/a.class... processing com/admob/plugin/b.class...
> processing com/admob/plugin/c.class... processing
> com/admob/plugin/d.class... processing com/admob/plugin/e.class...
> processing com/admob/plugin/f.class... processing
> com/admob/plugin/g.class... processing com/admob/plugin/h.class...
> processing com/admob/plugin/i.class... processing
> com/admob/plugin/j.class... processing com/admob/plugin/k.class...
> processing archive plugins\.\google-play-services.jar... ignored
> resource META-INF/ ignored resource META-INF/MANIFEST.MF ignored
> resource com/ ignored resource com/google/ ignored resource
> com/google/ads/ processing com/google/ads/AdRequest.class...
> processing com/google/ads/AdRequest$ErrorCode.class... processing
> com/google/ads/AdRequest$Gender.class... processing
> com/google/ads/AdSize.class... ignored resource
> com/google/ads/mediation/ processing
> com/google/ads/mediation/AbstractAdViewAdapter.class... processing
> com/google/ads/mediation/AbstractAdViewAdapter$zza.class... processing
> com/google/ads/mediation/AbstractAdViewAdapter$zzb.class... processing
> com/google/ads/mediation/Abstra<message truncated> </p> </body>
> </html>'
答案 0 :(得分:1)
这是因为您的项目中有imports
个重复项。可能有两个.jar文件,两个不同的插件具有不同的名称,但它们具有相同的功能。
您应该检查Assets/Plugins/Android/
中的插件列表,确保它们重复。
答案 1 :(得分:0)
这对我有用(请参阅此处https://github.com/googleads/googleads-mobile-unity/issues/299):
首先导入Google Analytics插件,删除Assets / PlayServicesResolver /目录中的内容,然后导入AdMob插件。
通过以下代码手动将Google Analytics添加为Play服务依赖项。此代码可以添加到AdMobDependencies.cs文件或声明Play服务依赖项的新文件中。
Google.VersionHandler.InvokeInstanceMethod(svcSupport,&#34; DependOn&#34;,new object [] {&#34; com.google.android.gms&#34;,&#34; play-services-analytics&# 34;,&#34; LATEST&#34;},namedArgs:new Dictionary(){{&#34; packageIds&#34;,new string [] {&#34; extra-google-m2repository&#34;,&# 34; extra-android-m2repository&#34;}}});
如果发生错误,退出Unity,从项目的Assets / Plugins / Android目录中删除所有Play服务AAR,并删除文件&#34; GoogleDependencyAdMobUnity.xml&#34;和#34; GoogleAarExplodeCache.xml&#34;在&#34; ProjectSettings&#34;文件夹并重启Unity。
启动Unity并让Play服务解析器重新导入相应的文件。
之后应该有效。