可能的错误
插件集成错误
插屏广告 Unity Ads 未显示,错误类型“全屏视图不正确”
在 iOS 上启动插屏广告时,可能会出现“全屏视图不正确”类型的错误。如果出现此问题,请确保您在 Build Phases
设置中的 Copy Bundle Resource 下添加了值 YandexMobileAdsBundle.bundle
。如果该值缺失,请添加它。
Yandex 聚合中的错误
重复的类:“在模块中发现重复的类 com.unity3d.ads.BuildConfig...”
如果您安装了 Unity Ads 模块,则构建将失败并出现类重复错误:
CommandInvokationFailure: Gradle build failed.
/Applications/Unity/Hub/Editor/2021.3.6f1/PlaybackEngines/AndroidPlayer/OpenJDK/bin/java -classpath "/Applications/Unity/Hub/Editor/2021.3.6f1/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
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 com.unity3d.ads.BuildConfig found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.IUnityAdsInitializationListener found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.IUnityAdsLoadListener found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.IUnityAdsShowListener found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.IUnityAdsTokenListener found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.UnityAds found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.UnityAds$UnityAdsInitializationError found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.UnityAds$UnityAdsLoadError found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.UnityAds$UnityAdsShowCompletionState found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.UnityAds$UnityAdsShowError found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.UnityAdsBaseOptions found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.UnityAdsLoadOptions found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.UnityAdsShowOptions found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.metadata.InAppPurchaseMetaData found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.metadata.MediationMetaData found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
Duplicate class com.unity3d.ads.metadata.MetaData found in modules jetified-UnityAds-runtime.jar (:UnityAds:) and jetified-com.unity3d.ads.unity-ads-4.2.1-runtime.jar (:com.unity3d.ads.unity-ads-4.2.1:)
...
要修复此错误,请移除 Unity Ads 模块 (Window → Package Manager)。