奖励视频AdMob中介,Applovin和Chartboost - 无法加载

时间:2016-09-12 14:12:56

标签: android admob chartboost applovin

我在使用Applovin和Chartboost实施AdMob Rewarded Video Mediation时被困3天,代码完全可以找到,但是当我启动应用程序时,它说" onRewardedVideoAdFailedToLoad"和广告不会显示。以下是我的代码,如果我在代码中犯了任何错误,请帮助我。

import com.applovin.sdk.AppLovinSdk;
import com.chartboost.sdk.Chartboost;
import com.google.ads.mediation.chartboost.ChartboostAdapter;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;

public class MainActivity extends Activity implements RewardedVideoAdListener {
private Button rewarded_video;
private RewardedVideoAd mAd;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

    AppLovinSdk.initializeSdk(getApplicationContext());
    AppLovinIncentivizedInterstitial myIncent = AppLovinIncentivizedInterstitial.create(this);
    myIncent.preload(null);

    Chartboost.startWithAppId(this, "xxxxxx", "xxxxxx");
    Chartboost.onCreate(this);

    MobileAds.initialize(this, APP_ID);
    mAd = MobileAds.getRewardedVideoAdInstance(this);
    mAd.setRewardedVideoAdListener(this);

    Bundle bundle = new Bundle();
    bundle.putBoolean("mute_audio", true);
    AdRequest adRequest = new AdRequest.Builder()
            .addNetworkExtrasBundle(ChartboostAdapter.class, bundle)
            .addNetworkExtrasBundle(ApplovinAdapter.class, bundle)
            .build();
    mAd.loadAd(AD_UNIT_ID, adRequest);

    rewarded_video = (Button) findViewById(R.id.rewarded_interstitial);
    rewarded_video.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mAd.isLoaded()) {
                mAd.show();
            }
        }
    });

}
@Override
public void onResume() {
    mAd.resume(this);
    super.onResume();
    Chartboost.onResume(this);
}
@Override
public void onPause() {
    mAd.pause(this);
    super.onPause();
    Chartboost.onPause(this);
}
@Override
public void onDestroy() {
    mAd.destroy(this);
    super.onDestroy();
    Chartboost.onDestroy(this);
}
@Override
public void onStop() {
    super.onStop();
    Chartboost.onStop(this);
}


@Override
public void onBackPressed() {
    // If an interstitial is on screen, close it.
    if (Chartboost.onBackPressed())
        return;
    else
        super.onBackPressed();
}



@Override
public void onRewardedVideoAdLeftApplication() {
    Toast.makeText(this, "onRewardedVideoAdLeftApplication", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdClosed() {
    Toast.makeText(this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
    Toast.makeText(this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
    //rewarded_video.setVisibility(View.GONE);
}

@Override
public void onRewardedVideoAdLoaded() {
    Toast.makeText(this, "onRewardedVideoAdLoaded", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoAdOpened() {
   Toast.makeText(this, "onRewardedVideoAdOpened", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewarded(RewardItem reward) {

}

@Override
public void onRewardedVideoStarted() {
    Toast.makeText(this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}
}

非常感谢你的帮助。

1 个答案:

答案 0 :(得分:2)

您是尝试通过AdMob调解AppLoving和Chartboost,还是尝试在Admob之外调用AppLovin和Chartboost SDK?

您似乎正在尝试单独初始化AppLovin和Chartboost SDK,然后尝试使用AdMob本身的展示调用,而这两个广告来源不受影响。我检查的最后一次,AdMob本身并不支持奖励视频,而是依赖其他广告网络来源来显示奖励视频,这可能是您没有得到任何东西的原因。只是旁注,您已经在AdMob的仪表板中设置了所有内容,是吗? (如设置中介来源和设置正确的广告单元一样)

为了使代码现在正常运行,您需要使用Chartboost或AppLovin自己的广告展示来展示奖励视频,而不是AdMob的' S。如果您正在尝试进行调解,AdMob会在their site上提供指导,帮助您解决问题。他们还有AppLovin as well as all of their approved integration partners的指南。

希望这有帮助。