我測試了橫幅廣告與測試ID顯示,它在顯示精細,在那之後我procceeded改變adUnitId設置到實際的ID的AdMob給了我和我在應用程序分類中初始化MobileAds。我在Play商店中發佈了我的應用,並將其關聯到AdMob,並配置了付款資料。 AdMob表示橫幅廣告處於活動狀態,但我下載了我的應用並重新安裝,並且廣告未顯示。我可以錯過一些步驟嗎?Android的AdMob的面板說,橫幅廣告是積極的,但它不是我的應用程序
相關代碼:
這是應用程序類:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileAds.initialize(getApplicationContext(), "ca-app-pub-8983537837429131~3925299209");
}
在橫幅廣告是爲了顯示活動:
public class EntryActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_entry);
Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
而且它的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/entryActivityLayout"
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/libs/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="com.bastardo.francisco.fitjournal.activities.EntryActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="My-banner-ad-Id"/>
</RelativeLayout>
正如我所說,測試廣告顯示得很好,但真正的廣告沒有顯示。我的應用已與AdMob中的Play商店關聯,並且我已經配置了付款資料。還有其他的步驟嗎?我需要等多久才能顯示應用程序?
你看到日誌什麼? –
我連接了設備並觀看了logcat一分鐘,但我什麼也沒看到。反正一個朋友告訴我他可以看到廣告。也許我不能看到他們,因爲我是開發人員? –