已經嘗試了很多東西。浪費了一天,看起來很容易。 當我打開我的應用程序時,廣告不顯示。」廣告不可見,不會刷新廣告。「
一切正常無誤,但只是廣告根本不顯示。
代碼和logcat的如下
MainActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MobileAds.initialize(getApplicationContext(), "***");
// " *** " is replacement for AdID and AdunitID
setContentView(R.layout.activity_main);
adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("45051C497E3954E140EC02E9C7B31B3C")
.build();
adView.loadAd(adRequest);
}
XML:
<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"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
tools:context="a1440.MainActivity"
android:elevation="1dp"
android:padding="15dp">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
ads:adSize = "BANNER"
ads:adUnitId= "******"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp" />
的logcat:
W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 16437
I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest
https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.appcache", source: htt://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: htt://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: htt://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
I/Ads: Ad is not visible. Not refreshing ad. I/Ads: Scheduling ad refresh 60000 milliseconds from now. I/Ads: Ad is not visible. Not refreshing ad.
I/Ads: Scheduling ad refresh 60000 milliseconds from now.
你確定你在MainActivity中調用了像'adView.onResume()','onPause()'等嗎? – Sufian