小编use*_*163的帖子

Admob测试广告未显示

这是我的第一个Android应用程序,我正在尝试使用我的应用程序的admob广告,但它不工作,尽管我已经完成了所有.

这是与广告相关的活动中的代码

     protected void onCreate(Bundle savedInstanceState) {
........

    LinearLayout rootLayout = (LinearLayout) findViewById(R.id.ForViewAd);

    AdView adView = new AdView(this);
    adView.setAdSize(AdSize.SMART_BANNER);
   //i've gotten the test ad id by first setting this as 'abc'
   //and then reading off the logcat
    adView.setAdUnitId("XXXXXXXXX");

    rootLayout.addView(adView, 0);

    AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
        .addTestDevice("XXXXXXXXXX")
        .build();
    adView.loadAd(adRequest);
Run Code Online (Sandbox Code Playgroud)

以下是我的XML代码

     <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout   
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     .......

     <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_centerHorizontal="true"
     android:orientation="horizontal" >


     <com.google.ads.AdView 
                android:id="@+id/ForViewAd"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 /> 
     </LinearLayout>
    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

在模拟器上运行应用程序时的logcat读数既奇怪又令人困惑

      09-28 15:28:21.076: E/Trace(968): error opening …
Run Code Online (Sandbox Code Playgroud)

android admob

3
推荐指数
1
解决办法
5740
查看次数

标签 统计

admob ×1

android ×1