Recently, I made an android app. After that, I have opened my account in AdMob and entered my app. I have got an App ID and Unit ID. For the first time, I tested my App with testing ID codes from developers.google.com. It worked well. But I have put IDs which are from AdMob in my codes. As a result, It is not displaying. Here is my Manifest.xml file

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     package="com.example.myapp2">     <uses-permission android:name="android.permission.INTERNET" />     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />     <application         android:allowBackup="true"         android:icon="@mipmap/ic_launcher"         android:label="Lotin-Kirill Converter"         android:roundIcon="@mipmap/ic_launcher_round"         android:supportsRtl="true"         android:theme="@style/AppTheme">         <meta-data             android:name="com.google.android.gms.ads.APPLICATION_ID"             android:value="ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx"/>         <activity             android:name="com.example.myapp2.Splash"             android:screenOrientation="portrait"             tools:ignore="LockedOrientationActivity">             <intent-filter>                 <action android:name="android.intent.action.MAIN" />                 <category android:name="android.intent.category.LAUNCHER" />             </intent-filter>         </activity>         <activity             android:name="com.example.myapp2.MainActivity">         </activity>         <meta-data             android:name="preloaded_fonts"             android:resource="@array/preloaded_fonts" />     </application> </manifest> 

It is build.gradle(:app)

apply plugin: 'com.android.application' android {     compileSdkVersion 29     buildToolsVersion "29.0.3"     defaultConfig {         applicationId "com.example.myapp2"         minSdkVersion 16         targetSdkVersion 29         versionCode 1         versionName "1.0"         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"     }     buildTypes {         release {             minifyEnabled false             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'         }     } } dependencies {     implementation fileTree(dir: 'libs', include: ['*.jar'])     implementation 'androidx.appcompat:appcompat:1.1.0'     implementation 'androidx.constraintlayout:constraintlayout:1.1.3'     implementation 'com.google.android.gms:play-services-ads:19.2.0'     testImplementation 'junit:junit:4.12'     androidTestImplementation 'androidx.test.ext:junit:1.1.1'     androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' } 

Here is MainActivity.java

package com.example.myapp2; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.content.DialogInterface; import android.os.Bundle; import android.os.Handler; import android.os.StrictMode; import android.view.View; import android.webkit.WebView; import android.widget.Toast; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdSize; import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.MobileAds; import com.google.android.gms.ads.initialization.InitializationStatus; import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; public class MainActivity extends AppCompatActivity {     WebView view;     AdView mAdview;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         MobileAds.initialize(this, new OnInitializationCompleteListener() {             @Override             public void onInitializationComplete(InitializationStatus initializationStatus) {             }         });         mAdview = (AdView)findViewById(R.id.adView);         AdRequest adRequest = new AdRequest.Builder().build();         mAdview.loadAd(adRequest);         StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();         StrictMode.setVmPolicy(builder.build());         view = (WebView) this.findViewById(R.id.webView);         view.getSettings().setJavaScriptEnabled(true);         view.getSettings().setDatabaseEnabled(true);         view.getSettings().setDatabasePath("/data/data/" + view.getContext().getPackageName() + "/databases/");         view.getSettings().setDomStorageEnabled(true);         view.getSettings().setLoadsImagesAutomatically(true);         view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);         view.loadUrl("file:///android_asset/test.html");     }     boolean doubleBackToExitPressedOnce = false;     @Override     public void onBackPressed() {         if (doubleBackToExitPressedOnce) {             new AlertDialog.Builder(this)                     .setTitle("Lotin-Kirill Converter.")                     .setMessage("Dasturdan chiqmoqchimisiz?")                     .setPositiveButton("Ha",                             new DialogInterface.OnClickListener() {                                 @Override                                 public void onClick(DialogInterface dialog,                                                     int which) {                                     finish();                                 }                             }).setNegativeButton("Yo'q", null).show();             return;         }         this.doubleBackToExitPressedOnce = true;         Toast.makeText(this, "Iltimos, Dasturdan chiqish uchun yana bir marta bosing!", Toast.LENGTH_SHORT).show();         new Handler().postDelayed(new Runnable() {             @Override             public void run() {                 doubleBackToExitPressedOnce=false;             }         }, 2000);     } } 

It is activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     tools:context=".MainActivity">     <WebView         android:id="@+id/webView"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         app:layout_constraintBottom_toBottomOf="parent"         app:layout_constraintEnd_toEndOf="parent"         app:layout_constraintStart_toStartOf="parent">     </WebView>     <com.google.android.gms.ads.AdView         android:id="@+id/adView"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentBottom="true"         android:layout_centerHorizontal="true"         app:adSize="BANNER"         app:adUnitId="ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx" /> </RelativeLayout> 

If you find my mistake, Please help me! Thank you for your attention!

Tag:google-ads-api, admob, android, ads

3 comments.

  1. Marlon

    Newly created admob IDs will not work immediately, you have to wait. From my experience it takes about a day of waiting for the actual IDs to work.

    When creating an app that you plan to monetize, create the admob IDs and Ad units ahead of time. You can edit its details later but the IDs will definitely be working when its time for testing and implementing them.

  2. ziddy

    try to test your admob enabled app in other devices. Admob has trouble loading real ads in devices that used for testing it. Also it may take a while for ads to appear

  3. René Jörg Spies

    Have you set up any Mediation Group?

    If no, then create one.

    If yes, then you just have to wait until your request is populated. Will take up some time up to a couple of days.

Add a new comment.