使用admob的麻烦,但我不知道为什么

时间:2014-08-09 19:50:08

标签: java android eclipse

我遇到了一些麻烦......

我为我的项目导入了这个:adt-bundle-windows-x86_64-20140702 \ sdk \ extras \ google \ google_play_services \ libproject \ google-play-services_lib

并且有示例,我使用它,但没有任何工作:( ADT-束 - 窗口x86_64-20140702 \ SDK \额外\谷歌\ google_play_services \样品\的AdMob 我改变了我的d_unit_id。但我仍然感到愤怒

01-03 06:52:49.312: W/Ads(16453): Failed to load ad: 3
01-03 06:53:49.382: W/GooglePlayServicesUtil(16453): Google Play services out of date.  Requires 5089000 but found 4325012
01-03 06:53:49.382: E/GooglePlayServicesUtil(16453): GooglePlayServices not available due to error 2
01-03 06:53:49.398: W/GooglePlayServicesUtil(16453): Google Play services out of date.  Requires 5089000 but found 4325012
01-03 06:53:49.398: E/GooglePlayServicesUtil(16453): GooglePlayServices not available due to error 2

而且是恐怖     01-03 06:52:49.312:W / Ads(16453):无法加载广告:3

我将jdk 1.7中的编译和android更改为4.4W。 并且我记录https://apps.admob.com并从那里复制ad_unit_id并且msut正在工作,但我总是得到aror和adwartismant不能用于例子:(

有清单文件

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.gms.samples.ads"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="18" />

    <!-- Used to request banner and interstitial ads. -->
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- Used to avoid sending an ad request if there is no connectivity. -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name="com.google.android.gms.samples.ads.GoogleAdsSampleActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".BannerXmlActivity"
            android:label="@string/banner_in_xml"/>
        <activity android:name=".BannerCodeActivity"
            android:label="@string/banner_in_code"/>
        <activity android:name=".InterstitialActivity"
            android:label="@string/interstitial"/>
        <!-- Activity required to show ad overlays. -->
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>

</manifest>

并且有横幅代码活动:

package com.google.android.gms.samples.ads;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;

import android.app.Activity;
import android.os.Bundle;
import android.widget.RelativeLayout;

/**
 * Example of including a Google banner ad in code and listening for ad events.
 */
public class BannerCodeActivity extends Activity {
    private AdView mAdView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banner_code_ad_listener);

        mAdView = new AdView(this);
        mAdView.setAdUnitId(getResources().getString(R.string.ad_unit_id));
        mAdView.setAdSize(AdSize.BANNER);
        mAdView.setAdListener(new ToastAdListener(this));
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.mainLayout);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        layout.addView(mAdView, params);
        mAdView.loadAd(new AdRequest.Builder().build());
    }

    @Override
    protected void onPause() {
        mAdView.pause();
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mAdView.resume();
    }

    @Override
    protected void onDestroy() {
        mAdView.destroy();
        super.onDestroy();
    }
}

和我的xml文件:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</RelativeLayout>

我的项目有条理:http://prntscr.com/4b7c5f

我在笔记3中得到了这个错误:

08-09 22:20:04.245: E/GooglePlayServicesUtil(22599): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
08-09 22:20:04.275: E/GooglePlayServicesUtil(22599): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
08-09 22:20:04.285: E/GooglePlayServicesUtil(22599): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
08-09 22:20:04.295: E/GooglePlayServicesUtil(22599): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
08-09 22:20:04.355: W/Ads(22599): There was a problem getting an ad response. ErrorCode: 2
08-09 22:20:04.355: I/Ads(22599): Scheduling ad refresh 60000 milliseconds from now.
08-09 22:20:04.355: W/Ads(22599): Failed to load ad: 2

0 个答案:

没有答案