Can´t load rewarded videos from admob - android

i have problems with the admob rewarded videos. i followed all the steps from here:
https://developers.google.com/admob/android/quick-start?hl=es-419#import_the_mobile_ads_sdk
https://developers.google.com/admob/android/rewarded-video?hl=es-419
But when i run the app it said video fails to load. I don´t understand the problem, it works fine with the test ads.
MainActivity:
public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {
Button boton;
private RewardedVideoAd mRewardedVideoAd;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
boton = (Button)findViewById(R.id.boton);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "ca-app-pub-7147850182235133~6727239853");
// Use an activity context to get the rewarded video instance.
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
}
private void loadRewardedVideoAd() {
mRewardedVideoAd.loadAd("ca-app-pub-7147850182235133/4302033289",
new AdRequest.Builder().build());
}
#Override
public void onRewarded(RewardItem reward) {
Toast.makeText(this, "onRewarded! currency: " + reward.getType() + " amount: " +
reward.getAmount(), Toast.LENGTH_SHORT).show();
// Reward the user.
}
#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();
}
#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 onRewardedVideoStarted() {
Toast.makeText(this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}
#Override
public void onRewardedVideoCompleted() {
Toast.makeText(this, "onRewardedVideoCompleted", Toast.LENGTH_SHORT).show();
}
public void boton(View view){
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}
}
}

There can be multiple reasons that ads might not show up properly,
Make sure that your payment details are correct.This might take
about a day to fully active until then admob wont provide you with
any ads.
Try troubleshooting available at this link! .Make sure that every questions are clear and then answer.
Hope this helps...

Related

Rewarded video ad is being failed to load

I have created an app with the rewarded video ad. When I click the button, the ad is not being loaded. I have tried testing the ad unit id and also my admob id, but neither work. Whenever I click the button, it shows " No fill from ad server. Failed to load ad: 3 "
I don't known what to do.
MobileAds.initialize(getApplicationContext(),"ca-app-pub-4786107620829013~6803627405");
mad = MobileAds.getRewardedVideoAdInstance(this);
mad.setRewardedVideoAdListener(this);
mad.loadAd("ca-app-pub-xxxxxxxxxxx", new AdRequest.Builder().build());
public void Clicked(View view) {
if (mad.isLoaded())
{
mad.show();
}
}
#Override
public void onRewardedVideoAdLoaded() {
Toast.makeText(this, "Video loaded", Toast.LENGTH_SHORT).show();
}
#Override
public void onRewardedVideoAdOpened() {
Toast.makeText(this, "Video Opened", Toast.LENGTH_SHORT).show();
}
#Override
public void onRewardedVideoStarted() {
Toast.makeText(this, "Video Started", Toast.LENGTH_SHORT).show();
}
#Override
public void onRewardedVideoAdClosed() {
}
#Override
public void onRewarded(RewardItem rewardItem) {
}
#Override
public void onRewardedVideoAdLeftApplication() {
}
#Override
public void onRewardedVideoAdFailedToLoad(int i) {
Toast.makeText(this, "Fail", Toast.LENGTH_SHORT).show();
}
#Override
public void onRewardedVideoCompleted() {
Toast.makeText(this, "Complete Video", Toast.LENGTH_SHORT).show();
}

Method does not override method from its superclass onRewarded()

so i am trying to implement video reward ads. But when i try to use the onRewarded method to reward the user it says "method does not override method from its superclass"
https://pastebin.com/Hp1zbuWW
#Override
public void onRewarded(RewardItem rewardItem) {
Toast.makeText(this, "onRewarded! currency: " + rewardItem.getType() + " amount: " +
rewardItem.getAmount(), Toast.LENGTH_SHORT).show();
}
I think you forgot to implement RewardedVideoAdListener in your activity.
public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {
private RewardedVideoAd mRewardedVideoAd;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this,
"ca-app-pub-3940256099942544~3347511713");
// Use an activity context to get the rewarded video instance.
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
}
private void loadRewardedVideoAd() {
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());
}
}
Then you can override methods like this.
#Override
public void onRewarded(RewardItem reward) {
Toast.makeText(this, "onRewarded! currency: " + reward.getType() + " amount: " +
reward.getAmount(), Toast.LENGTH_SHORT).show();
// Reward the user.
}
#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();
}
#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 onRewardedVideoStarted() {
Toast.makeText(this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}

Admob Reward Video Ad

This is my reward video code. What i want to do is a button with every click loads a reward video. The problems that faced me are, first the reward video loading takes much time to load and second the reward video sometimes is requested only once so what is the right way to start a reward video on every click with no delay?
rewardedVideoAd = MobileAds.getRewardedVideoAdInstance(MainActivity.this);
rewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().build());
rewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
#Override
public void onRewarded(RewardItem reward) {
}
#Override
public void onRewardedVideoAdLeftApplication() {}
#Override
public void onRewardedVideoAdClosed() {}
#Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
rewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",new AdRequest.Builder().build());
}
#Override
public void onRewardedVideoAdLoaded() {}
#Override
public void onRewardedVideoAdOpened() {}
#Override
public void onRewardedVideoStarted() {
rewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",new AdRequest.Builder().build());
}
});
and this is my button on click code
if (rewardedVideoAd.isLoaded()){
rewardedVideoAd.show();
}
i can shows video reward ads (only test ads) using below code.
public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {
private RewardedVideoAd mRewardedVideoAd;
private InterstitialAd mInterstitialAd;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, getResources().getString(R.string.app_id));
// Use an activity context to get the rewarded video instance.
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());
//getResources().getString(R.string.Video_reward_ad_unit_id)
mRewardedVideoAd.setRewardedVideoAdListener(this);
findViewById(R.id.btVideo).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}
}
});
mInterstitialAd = new InterstitialAd(MainActivity.this);
mInterstitialAd.setAdUnitId(getResources().getString(R.string.banner_ad_unit_id));
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener() {
#Override
public void onAdClosed() {
// Load the next interstitial.
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.show();
}
});
findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
});
}
#Override
protected void onStart() {
loadTestRewardedVideoAd();
MobileAds.setAppMuted(true);
super.onStart();
}
private void loadTestRewardedVideoAd() {
mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());
}
#Override
public void onRewardedVideoAdLoaded() {
Log.i("onRewardedVideoAdLoaded", "Ad Loaded");
}
#Override
public void onRewardedVideoAdOpened() {
Toast.makeText(this, "Ad OPEPED Now ", Toast.LENGTH_SHORT).show();
}
#Override
public void onRewardedVideoStarted() {
}
#Override
public void onRewardedVideoAdClosed() {
}
#Override
public void onRewarded(RewardItem reward) {
}
#Override
public void onRewardedVideoAdLeftApplication() {
Log.i("onRewardedVideoAdLeft", "END");
}
#Override
public void onRewardedVideoAdFailedToLoad(int i) {
Log.i("onRewardedVideoAdLeft", "END");
}
but this is only works with test device not on real device.

Rewarded video ad failed to load

Every time when i run the code its call onRewardedVideoAdFailedToLoad(int i) function. I am using codelabs example.
Sorry for bad English and thanks for helping me.
here is my code. I used many tutorial .
Is there anything I did it in the wrong way?
Or I just missed some steps?
public class Rewardedvideo extends AppCompatActivity implements
RewardedVideoAdListener {
RewardedVideoAd mAd;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rewardedvideo);
MobileAds.initialize(getApplicationContext(), "ca-app-pub-
3940256099942544~3347511713");
mAd=MobileAds.getRewardedVideoAdInstance(Rewardedvideo.this);
mAd.setRewardedVideoAdListener(this);
loadrewardedvideoAd();
}
public void loadrewardedvideoAd(){
if(!mAd.isLoaded()){
mAd.loadAd("ca-app-pub-3940256099942544/5224354917",new
AdRequest.Builder().build());
}
}
public void startvideo(){
if(mAd.isLoaded()){
mAd.show();
}
else {
mAd.loadAd("ca-app-pub-3940256099942544/5224354917",new
AdRequest.Builder().build());
mAd.show();
}
}
#Override
public void onRewarded(RewardItem reward) {
Toast.makeText(this, "onRewarded! currency: " + reward.getType() + "
amount: " +
reward.getAmount(), Toast.LENGTH_SHORT).show();
// Reward the user.
}
#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();
}
#Override
public void onRewardedVideoAdLoaded() {
Toast.makeText(this, "onRewardedVideoAdLoaded",
Toast.LENGTH_SHORT).show();
startvideo();
}
#Override
public void onRewardedVideoAdOpened() {
Toast.makeText(this, "onRewardedVideoAdOpened",
Toast.LENGTH_SHORT).show();
}
#Override
public void onRewardedVideoStarted() {
Toast.makeText(this, "onRewardedVideoStarted",
Toast.LENGTH_SHORT).show();
}
#Override
public void onResume() {
mAd.resume(this);
super.onResume();
}
#Override
public void onPause() {
mAd.pause(this);
super.onPause();
}
#Override
public void onDestroy() {
mAd.destroy(this);
super.onDestroy();
}
}
here is my code. I used many tutorial .
Is there anything I did it in the wrong way?
Or I just missed some steps?
I think this is not get video source.
try again after few time

AdMob rewarded videos always onRewardedVideoAdFailedToLoad

My code is here
I have test it on my device I also integrate this app on firebase.
but it never go to onRewarded it always call onRewardedFaild why sir?
can anyone help me.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize the Mobile Ads SDK.
MobileAds.initialize(this,APP_ID);
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
// Create the "retry" button, which tries to show an interstitial between game plays.
mRetryButton = ((Button) findViewById(R.id.retry_button));
mRetryButton.setVisibility(View.INVISIBLE);
mRetryButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
startGame();
}
});
// Create the "show" button, which shows a rewarded video if one is loaded.
mShowVideoButton = ((Button) findViewById(R.id.watch_video));
mShowVideoButton.setVisibility(View.INVISIBLE);
mShowVideoButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
showRewardedVideo();
}
});
// Display current coin count to user.
mCoinCountText = ((TextView) findViewById(R.id.coin_count_text));
mCoinCount = 0;
mCoinCountText.setText("Coins: " + mCoinCount);
startGame();
}
#Override
public void onPause() {
super.onPause();
pauseGame();
mRewardedVideoAd.pause(this);
}
#Override
public void onResume() {
super.onResume();
if (!mGameOver && mGamePaused) {
resumeGame();
}
mRewardedVideoAd.resume(this);
}
private void pauseGame() {
mCountDownTimer.cancel();
mGamePaused = true;
}
private void resumeGame() {
createTimer(mTimeRemaining);
mGamePaused = false;
}
private void loadRewardedVideoAd() {
if (!mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.loadAd(AD_UNIT_ID, new AdRequest.Builder().build());
/* AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("40C4DDA8F53FFA9BA5B61261E0CA28AB") // Test devices don't work work with rewarded video ads.
.build();
mRewardedVideoAd.loadAd(AD_UNIT_ID, adRequest);*/
}
}
private void addCoins(int coins) {
mCoinCount = mCoinCount + coins;
mCoinCountText.setText("Coins: " + mCoinCount);
}
private void startGame() {
// Hide the retry button, load the ad, and start the timer.
mRetryButton.setVisibility(View.INVISIBLE);
mShowVideoButton.setVisibility(View.VISIBLE);
loadRewardedVideoAd();
createTimer(COUNTER_TIME);
mGamePaused = false;
mGameOver = false;
}
// Create the game timer, which counts down to the end of the level
// and shows the "retry" button.
private void createTimer(long time) {
final TextView textView = ((TextView) findViewById(R.id.timer));
if (mCountDownTimer != null) {
mCountDownTimer.cancel();
}
mCountDownTimer = new CountDownTimer(time * 1000, 50) {
#Override
public void onTick(long millisUnitFinished) {
mTimeRemaining = ((millisUnitFinished / 1000) + 1);
textView.setText("seconds remaining: " + mTimeRemaining);
}
#Override
public void onFinish() {
if (mRewardedVideoAd.isLoaded()) {
mShowVideoButton.setVisibility(View.VISIBLE);
}
textView.setText("You Lose!");
addCoins(GAME_OVER_REWARD);
mRetryButton.setVisibility(View.VISIBLE);
mGameOver = true;
}
};
mCountDownTimer.start();
}
private void showRewardedVideo() {
mShowVideoButton.setVisibility(View.INVISIBLE);
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}
}
#Override
public void onRewardedVideoAdLeftApplication() {
Toast.makeText(this, "onRewardedVideoAdLeftApplication", Toast.LENGTH_SHORT).show();
}
#Override
public void onRewardedVideoAdClosed() {
Toast.makeText(this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
// Preload the next video ad.
loadRewardedVideoAd();
}
#Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
Toast.makeText(this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}
#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) {
Toast.makeText(this,
String.format(" onRewarded! currency: %s amount: %d", reward.getType(),
reward.getAmount()),
Toast.LENGTH_SHORT).show();
addCoins(reward.getAmount());
}
#Override
public void onRewardedVideoStarted() {
Toast.makeText(this, "onRewardedVideoStarted", Toast.LENGTH_SHORT).show();
}
I am using my Ad_Unit_ID Live not tested Device ID

Categories

Resources