Banner Admob with display problems

Asked

Viewed 51 times

-1

I developed an Android app in Java and added a banner on it to display ads. In test mode it is displayed, but when I put the Admob banner code it does not display the banner on the screen, but the Admob request counter is increasing.

I did the entire code implementation with the Admob manuals.

Using the Get Started to instantiate the ads.

Banner Ads to place a banner in the application.

My Admob account is over two weeks old, I’ve had some ads shown, but not anymore. My account is also not blocked.

The codes are as follows:

build. Grid (Module:app)

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.material:material:1.1.0'
    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'
}

Androidmanifest.XML

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-7206755174693920~2499609222" />

Activity_main.XML

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        ads:adSize= "BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
        ads:layout_constraintBottom_toBottomOf="parent"
        ads:layout_constraintEnd_toEndOf="parent"
        ads:layout_constraintStart_toStartOf="parent">
    </com.google.android.gms.ads.AdView>

Mainactivity.java

public class MainActivity extends AppCompatActivity {
    AdView mAdView;
    AdRequest adRequest;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        mAdView = findViewById(R.id.adView);

        MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
        });

        adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
    }
}        

I saw some people with a similar problem. In that case, the person had written the wrong meta-date. In that same question the implementation of the MainActivity.java was different from mine, I left mine equal, but still did not succeed.

I appreciate the help.

1 answer

0

The problem has been solved.

It turns out that Admob has changed its ad display policies and the app review may take two to fifteen days, in which time you won’t be able to display any ads.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.