我下载了最新的Unity Ads SDK并按照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
我错过了什么?
答案 0 :(得分:0)
错误是IUnityAdsListener
(第三个初始化参数)是必需的,不能为null。
修复方法是将监听器添加到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() {
}
});