Unity GoogleMobileAdsMediationTestSuite 抛出异常 setAdListener must be called on the main UI thread

Unity GoogleMobileAdsMediationTestSuite throws exception setAdListener must be called on the main UI thread

我尝试将 MediationTestSuite 实现到我的 Unity 游戏中,但出现此异常,因此看不到 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 东西?

它绝对不是 的副本,因为它在 Unity 中,我无法访问 MeditationTestSuite 库代码。

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