Libgdx通过adcolony和charboost推荐了视频admob中介

时间:2018-07-18 08:33:48

标签: libgdx admob chartboost adcolony

我正面临使我疯狂的问题 我已经在自己的游戏中设置了奖励视频。

只要我将admob用作唯一的奖励视频来源,我就会奖励一个受奖励的视频侦听器,一切正常。 现在,我添加了2个中介网络chartboost和广告殖民地。 我能够看到视频的奖励,但是一旦视频结束,我就会收到一个错误,我无法理解如何执行

上面的错误,对于adcolony和chartboost都是相同的

java.lang.NoSuchMethodError: No interface method onVideoCompleted(Lcom/google/android/gms/ads/reward/mediation/MediationRewardedVideoAdAdapter;)V in class Lcom/google/android/gms/ads/reward/mediation/MediationRewardedVideoAdListener; or its super classes (declaration of 'com.google.android.gms.ads.reward.mediation.MediationRewardedVideoAdListener' appears in /data/app/mypackage/base.apk)
at com.jirbo.adcolony.AdColonyAdListener.onReward(AdColonyAdListener.java:138)
at com.adcolony.sdk.l$10.run(SourceFile:947)
at android.app.Activity.runOnUiThread(Activity.java:6029)
at com.adcolony.sdk.aw.a(SourceFile:212)
at com.adcolony.sdk.l.d(SourceFile:944)
at com.adcolony.sdk.l$15.a(SourceFile:217)
at com.adcolony.sdk.ag.a(SourceFile:188)
at com.adcolony.sdk.ag$2.run(SourceFile:157)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:165)

我的代码在android laucher类上是这样的

import Intreface.AdHandler;
import Intreface.GoogleServices;
import Intreface.IntestiliadAd;
import Intreface.VideoEventListener;


public class AndroidLauncher extends AndroidApplication implements 
GoogleServices, RewardedVideoAdListener, AdHandler , IntestiliadAd{
private RewardedVideoAd adRewardedVideoView;
private static final String REWARDED_VIDEO_AD_UNIT_ID = 
 ".................................";
private static String TAG = "AndroidLauncher";
private static final String AD_UNIT_ID_INTERSTITIAL = 
".............................";
private static final String AD_UNIT_ID_BANNER = 
".............................";
private final int SHOW_ADS = 1;
private final int HIDE_ADS = 0;
protected AdView adView;
private InterstitialAd interstitialAd;



Handler handler = new Handler(){

@Override
public void handleMessage(Message msg) {
    switch (msg.what){
        case SHOW_ADS:
            adView.setVisibility(View.VISIBLE);
            break;
        case HIDE_ADS:
            adView.setVisibility(View.GONE);
            break;

    }
}
};


private boolean is_video_ad_loaded;
private VideoEventListener vel;
private MediationAdapter mediationAdapter;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


RelativeLayout layout = new RelativeLayout(this);

AndroidApplicationConfiguration config = new 
AndroidApplicationConfiguration();
View gameView = initializeForView(new Farbbit(this,this,this), config);
layout.addView(gameView);
setupRewarded();

interstitialAd = new InterstitialAd(this);
adView = new AdView(this);
adView.setAdListener(new AdListener() {
    @Override
    public void onAdLoaded() {
        super.onAdLoaded();
        Log.i(TAG, "Ad loaded...");
    }
});

adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(AD_UNIT_ID_BANNER);
interstitialAd.setAdUnitId(AD_UNIT_ID_INTERSTITIAL);

interstitialAd.setAdListener(new AdListener() {

@Override
public void onAdLoaded() {

             }
@Override
 public void onAdClosed() {
           }
});



AdRequest.Builder builder = new AdRequest.Builder();
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
        RelativeLayout.LayoutParams.WRAP_CONTENT,
        RelativeLayout.LayoutParams.WRAP_CONTENT
);
layout.addView(adView ,adParams);

adView.loadAd(builder.build());
setContentView(layout);

}
@Override
public void showOrLoadInterstital() {
    try {
          runOnUiThread(new Runnable() {
public void run() {
                      if (interstitialAd.isLoaded()) {
                            interstitialAd.show();

                          }
                      else {
                            AdRequest interstitialRequest = new 
AdRequest.Builder().build();
                           interstitialAd.loadAd(interstitialRequest);

                          }
                    }
 });
        } catch (Exception e) {
        }
  }

 @Override
  public void loadInterstital() {
  try {
    runOnUiThread(new Runnable() {
        public void run() {
  if (!interstitialAd.isLoaded()){
    AdRequest interstitialRequest = new AdRequest.Builder().build();
    interstitialAd.loadAd(interstitialRequest);
}
}   });
} catch (Exception e) {
}
}

public void loadRewardedVideoAd() {
adRewardedVideoView.loadAd(REWARDED_VIDEO_AD_UNIT_ID, new 
AdRequest.Builder().build());
}

public void setupRewarded() {
adRewardedVideoView = MobileAds.getRewardedVideoAdInstance(this);
adRewardedVideoView.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
}


public boolean hasVideoLoaded() {
if (is_video_ad_loaded) {
    return true;
}
runOnUiThread(new Runnable() {
    public void run() {
        if (!adRewardedVideoView.isLoaded()) {
            loadRewardedVideoAd();
        }
    }
});
return false;
}

public void showRewardedVideoAd() {
runOnUiThread(new Runnable() {
    public void run() {
        if (adRewardedVideoView.isLoaded()) {
            adRewardedVideoView.show();
        } else {
            loadRewardedVideoAd();
        }
    }
});
}

@Override
public void onRewarded(RewardItem reward) {
 if (vel != null) {

    vel.onRewardedEvent(reward.getType(), reward.getAmount());
}
}

@Override
public void onRewardedVideoAdLeftApplication() {

}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {

}


@Override
public void onRewardedVideoAdClosed() {
is_video_ad_loaded = false;
loadRewardedVideoAd();
if (vel != null) {
    vel.onRewardedVideoAdClosedEvent();
}
}

@Override
public void onRewardedVideoAdLoaded() {
if (vel != null) {
    vel.onRewardedVideoAdLoadedEvent();
}
is_video_ad_loaded = true;
}

@Override
public void onRewardedVideoAdOpened() {

}

@Override
public void onRewardedVideoStarted() {

}

public void setVideoEventListener(VideoEventListener listener) {
this.vel = listener;
}

@Override
public void showAds(boolean show) {
  handler.sendEmptyMessage(show ? SHOW_ADS : HIDE_ADS);
}


}

0 个答案:

没有答案