【问题标题】:Unity GoogleMobileAdsMediationTestSuite throws exception setAdListener must be called on the main UI threadUnity GoogleMobileAdsMediationTestSuite 抛出异常 setAdListener 必须在主 UI 线程上调用
【发布时间】:2019-11-15 12:09:39
【问题描述】:

我尝试在我的 Unity 游戏中实现 MediationTestSuite,但我遇到了这个异常,因此看不到 MediationTestSuite

例外:

java.lang.IllegalStateException: setAdListener must be called on the main UI thread.
        at lr.b(:com.google.android.gms.policy_ads_fdr_dynamite@21001000@21001000.272763194.272763194:1)
        at com.google.android.gms.ads.nonagon.shim.f.a(:com.google.android.gms.policy_ads_fdr_dynamite@21001000@21001000.272763194.272763194:14)
        at com.google.android.gms.ads.nonagon.shim.g.a(:com.google.android.gms.policy_ads_fdr_dynamite@21001000@21001000.272763194.272763194:4)
        at com.google.android.gms.ads.internal.client.ap.a(:com.google.android.gms.policy_ads_fdr_dynamite@21001000@21001000.272763194.272763194:62)
        at ff.onTransact(:com.google.android.gms.policy_ads_fdr_dynamite@21001000@21001000.272763194.272763194:4)
        at android.os.Binder.transact(Binder.java:667)

我的代码是

public void OnButtonClick()
{
    GoogleMobileAdsMediationTestSuite.Api.MediationTestSuite.Show();
}

绑定在场景中的单个按钮上。

​​​我尝试通过调度此调用直接在 Update 方法中执行此操作,还尝试创建空 Unity 项目并仅将 GoogleMobileAds-v4.1.0 + GoogleMobileAdsUnityAdsMediation + GoogleMobileAdsMediationTestSuite 添加到其中,所有这些都直接从 Google 链接下载.

我在这里遗漏了什么,还是仅仅是 MediationTestSuite 被窃听并在单独的线程中调用了一些 UI 内容?

它绝对不是 AdMob Interstitial and error isLoaded must be called on the main UI thread 的副本,因为它在 Unity 中,我无法访问 MeditationTestSuite 库代码。

【问题讨论】:

标签: android unity3d gradle exception googlemobileads


【解决方案1】:

嗯。一切都很简单。显然,当您统一构建没有“开发构建”标记时,MediationTestSuite 会引发这种异常。但我确实拥有它。情况是我应该在 gradle 构建任务中使用 assembleDebug 。 我遇到了这个问题,因为我通过导出到 android 项目而不是统一构建来手动构建我的 android。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多