Not showing TEST ads and REAL add Rewarded Video by Admob for Android

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Not showing TEST ads and REAL add Rewarded Video by Admob for Android



I am facing an error from last week, please help me better.
I implement RewardedVideo by Admob but I am getting error 3 and some time error 0.this both error facing me when I try both test ads and real ads.


RewardedVideo


Admob


error 3


error 0


test ads


real ads



My Code is below.


private RewardedVideoAd mRewardedVideoAd;
Button adsShow;
private static final String TAG = "MainActivity";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, "ca-app-pub-3940256099942544/5224354917");
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);

loadRewardedVideoAd();
adsShow=(Button)findViewById(R.id.mainidads);
adsShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mRewardedVideoAd.isLoaded()){
mRewardedVideoAd.show();
}
}
});

}
private void loadRewardedVideoAd() {

if(!mRewardedVideoAd.isLoaded()) {

mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
new AdRequest.Builder().build());

}
}

@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 onRewardedVideoAdClosed() {
loadRewardedVideoAd();
Toast.makeText(this, "onRewardedVideoAdClosed", Toast.LENGTH_SHORT).show();
}

@Override
public void onRewarded(RewardItem rewardItem) {
Toast.makeText(this, "onRewarded! currency: " + rewardItem.getType() + " amount: " +
rewardItem.getAmount(), Toast.LENGTH_SHORT).show();
}

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

@Override
public void onRewardedVideoAdFailedToLoad(int i) {
Toast.makeText(this, "onRewardedVideoAdFailedToLoad "+i, Toast.LENGTH_SHORT).show();
}

@Override
public void onRewardedVideoCompleted() {

}



my Dependency on build.gradle is


dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-ads:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.github.bumptech.glide:glide:4.4.0'
implementation 'com.android.support:customtabs:27.1.1'
}



Kinly please help me.




1 Answer
1



One of the reason you are getting error is you are initializing your ad with add unit ID instead of app ID.


// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");



reference - https://developers.google.com/admob/android/quick-start#initialize_mobileads



Change code to reflect correct app_id which is located in ( Admob Console -> App->App Settings->App ID )


setContentView(R.layout.activity_main);
MobileAds.initialize(this, "ca-app-pub-3940256099942544/5224354917");
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
mRewardedVideoAd.setRewardedVideoAdListener(this);



If this doesn't solve your problem please update your question with error log






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results