GooglePlayService AdMob

时间:2014-01-10 11:36:26

标签: java android admob adview

我正在尝试在我的应用程序中加入广告,我创建了AdMob帐户,然后按照教程(下载的API,导入的google-play-services / libraries / google-play-services_lib到工作区,在Java Build Path / Libraries中)已导入google-play-services_lib / libs / google-play-services,以及Java Build Path / Order and Export中的checked字段

在我的项目中我做了

布局活动_菜单

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent" >
     <com.google.android.gms.ads.AdView
       android:id="@+id/adView"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_alignParentBottom="true"
       ads:adUnitId="ca-app-pub-xxxxxxxxxxxxx/xxxxxxxx"
       ads:adSize="BANNER"
       /> 

java文件

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_menu);
     AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);
}

当我运行我的应用程序时,我可以看到广告正在显示,但我收到的警告很少

01-10 12:29:04.269: W/dalvikvm(2450): VFY: unable to resolve instance field 35
01-10 12:29:04.289: W/GooglePlayServicesUtil(2450): Google Play services is missing.
01-10 12:29:15.319: W/GooglePlayServicesUtil(2450): Google Play services is missing.

和错误

01-10 12:29:15.359: E/GooglePlayServicesUtil(2450): GooglePlayServices not available due to error 1

所以,尽管我得到了错误,但我已多次看到我的广告,但当我查看AdMob帐户时,它说我有0次观看。是因为我还没有发布我的应用程序,或者我可能需要做更多的事情?那个错误是什么?

编辑: AdMob网站刷新了,现在我看到了45个我的观点,但没有钱占这个,这些广告是PPC还是处于测试模式?我能以某种方式将它们改为PPV吗?

1 个答案:

答案 0 :(得分:0)

我不知道你的确切问题是什么,但我做了以下工作并且工作正常。

AdView adView = new AdView(this, AdSize.SMART_BANNER, "a152c65f562hc48b");
        AdRequest request = new AdRequest();
        adView.loadAd(request);
        // Add the adView to it
        layout.addView(adView); //layout is a RelativeLayout.
        // // Initiate a generic request to load it with an ad
        adView.loadAd(new AdRequest());