我遇到了问题:
我将Eclipse与ADT结合使用,横幅广告未在Google广告示例应用中显示,我不知道原因。
Mannifest:
<?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>
代码
setContentView(R.layout.activity_banner_code_ad_listener);
mAdView = new AdView(this);
mAdView.setAdUnitId("ca-app-pub-8xxxxxxxxxxxxxxx/4xxxxxxxxx");
mAdView.setAdSize(AdSize.BANNER);
final RelativeLayout layout = (RelativeLayout) findViewById(R.id.mainLayout);
layout.addView(mAdView);
mAdView.setAdListener(new ToastAdListener(this));
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("AAxAxxxAxAxxxAxxxAxxxAAxxAxxxAA")
.build();
mAdView.loadAd(adRequest);
项目特性:
target=android-18
android.library.reference.1=../google-play-services_lib
在LogCat中:
Google Play services out of date. Requires 6587000 but found 5089030
GooglePlayServices not available due to error 2
VFY: unable to resolve virtual method 8193: Landroid/webkit/WebView;.evaluateJavascript (Ljava/lang/String;Landroid/webkit/ValueCallback;)V
JS: The page at https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html displayed insecure content from file:///android_asset/webkit/android-weberror.png.
The page at https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html displayed insecure content from file:///android_asset/webkit/android-weberror.png.
JS: Uncaught ReferenceError: AFMA_buildAdURL is not defined (null:1)
Uncaught ReferenceError: AFMA_buildAdURL is not defined at null:1
申请工作,但没有横幅。听众,我看到我有一个内部错误。
互联网工作,我在项目中包含了google-play-services_lib rev 22。
我曾试过另一部手机,但同样的事情。
答案 0 :(得分:0)
始终使用最新目标构建项目:
android:targetSdkVersion="21"
还尝试通过SDK管理器更新您的Google Play服务(GMS)。
答案 1 :(得分:0)
您设备上的Google Play服务版本已过期。
在您的设备上,转到Google Play并查找更新。
答案 2 :(得分:0)
添加到清单
但将您的APPLICATION_ID指向第二行
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-11111111111111~222222222"/>