Unity Ads 无法显示广告:webapp 未初始化
Unity Ads cannot show ads: webapp not initialized
我下载了最新的 Unity Ads SDK and followed the instructions 以将其集成到我的 android 应用程序中。
UnityAds.init(this, "xxxxxxx", null);
初始化成功,日志显示广告已下载。
Initializing Unity Ads version 1508 with gameId xxxxxxx
Requesting Unity Ads ad plan from https://xxxxxxx
Unity Ads initialized with 3 campaigns and 2 zones
Unity Ads cache: File /storage/xxxxxxx/yyyyyyy.mp4 of 1445875 bytes downloaded in 9102ms
我尝试展示广告:
if (UnityAds.canShow()) {
UnityAds.show();
}
然后出现这个错误信息:
Unity Ads cannot show ads: webapp not initialized
我错过了什么?
错误是IUnityAdsListener
(第三个初始化参数)是必需的,不能为空。
修复方法是将侦听器添加到 init
方法,如下所示:
UnityAds.init(this, "xxxxxxx", new IUnityAdsListener() {
@Override
public void onHide() {
}
@Override
public void onShow() {
}
@Override
public void onVideoStarted() {
}
@Override
public void onVideoCompleted(String s, boolean b) {
}
@Override
public void onFetchCompleted() {
}
@Override
public void onFetchFailed() {
}
});
我下载了最新的 Unity Ads SDK and followed the instructions 以将其集成到我的 android 应用程序中。
UnityAds.init(this, "xxxxxxx", null);
初始化成功,日志显示广告已下载。
Initializing Unity Ads version 1508 with gameId xxxxxxx
Requesting Unity Ads ad plan from https://xxxxxxx
Unity Ads initialized with 3 campaigns and 2 zones
Unity Ads cache: File /storage/xxxxxxx/yyyyyyy.mp4 of 1445875 bytes downloaded in 9102ms
我尝试展示广告:
if (UnityAds.canShow()) {
UnityAds.show();
}
然后出现这个错误信息:
Unity Ads cannot show ads: webapp not initialized
我错过了什么?
错误是IUnityAdsListener
(第三个初始化参数)是必需的,不能为空。
修复方法是将侦听器添加到 init
方法,如下所示:
UnityAds.init(this, "xxxxxxx", new IUnityAdsListener() {
@Override
public void onHide() {
}
@Override
public void onShow() {
}
@Override
public void onVideoStarted() {
}
@Override
public void onVideoCompleted(String s, boolean b) {
}
@Override
public void onFetchCompleted() {
}
@Override
public void onFetchFailed() {
}
});