I have a problem implementing AdMob with my Android app, ads are not showing for my package name, I changed the name and everything works fine, I restored the prod name and everything stopped working with the error: no ad config, this is my first time using AdMob, which means the ads work for a while and then suddenly stop is not the case here, I don't suspect anything wrong with the code because I followed everything in the documentation and, as I said, everything works fine when I change the package name to a random string.
- Is app-ads.txt correct? yes, app-ads.txt file found and verified (100% of queries authorized)
- Policy center: no current issues, no disapproved apps
- App linked to admob? yes it is linked through google play and I noticed the icon is updated
- PIN verification: I still didn't reach the verification threshold
- Is Google Ads and Adsense linked to Admob? yes, and with the same email
- Admob status: Your account is approved
- App approval status: Ready (Ad serving enabled)
- App stores: Google Play
- Ad format: Rewarded
- Ads activity performance, Requests: 0 (ZERO)
Note 1: the email I am using on play console is diff from the email of admob / ads / adsense
Note 2: the prod app is already launched in google play store
Any help guys?
MainActivity.java:
package com.example.admob; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Toast; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.LoadAdError; import com.google.android.gms.ads.MobileAds; import com.google.android.gms.ads.OnUserEarnedRewardListener; import com.google.android.gms.ads.RequestConfiguration; import com.google.android.gms.ads.initialization.InitializationStatus; import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; import com.google.android.gms.ads.rewarded.RewardItem; import com.google.android.gms.ads.rewarded.RewardedAd; import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback; import java.util.Arrays; public class MainActivity extends AppCompatActivity { private RewardedAd mRewardedAd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /**/ RequestConfiguration configuration = new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("PEO7WS709MHDMHS0KA74LQ4KDPL9V8DJ")).build(); /**/ MobileAds.setRequestConfiguration(configuration); /**/ MobileAds.initialize(this, new OnInitializationCompleteListener() { @Override public void onInitializationComplete(InitializationStatus initializationStatus) { } }); AdRequest adRequest = new AdRequest.Builder().build(); RewardedAd.load(this, "ca-app-pub-2887021452579791/7518976046", adRequest, new RewardedAdLoadCallback() { @Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { // Handle the error. Log.d(TAG, loadAdError.getMessage()); Toast.makeText(MainActivity.this, loadAdError.getMessage(), Toast.LENGTH_SHORT).show(); mRewardedAd = null; } @Override public void onAdLoaded(@NonNull RewardedAd rewardedAd) { mRewardedAd = rewardedAd; Log.d(TAG, "Ad was loaded."); Toast.makeText(MainActivity.this, "Ad was loaded", Toast.LENGTH_SHORT).show(); } }); findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mRewardedAd != null) { Activity activityContext = MainActivity.this; mRewardedAd.show(activityContext, new OnUserEarnedRewardListener() { @Override public void onUserEarnedReward(@NonNull RewardItem rewardItem) { // Handle the reward. Log.d(TAG, "The user earned the reward."); Toast.makeText(MainActivity.this, "onUserEarnedReward", Toast.LENGTH_SHORT).show(); } }); } else { Log.d(TAG, "The rewarded ad wasn't ready yet."); Toast.makeText(MainActivity.this, "Not ready!", Toast.LENGTH_SHORT).show(); } } }); } }
Manifest.xml:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.admob"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AdMob"> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-2887021452579791~7783129272"/> <activity android:name=".MainActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>