【发布时间】:2015-01-18 11:11:36
【问题描述】:
我有一个问题:
我将 Eclipse 与 ADT 结合使用,但横幅未显示在 Google Ads 示例应用程序中,我不知道为什么。
清单:
<?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。
我在另一部手机上试过,但结果一样。
【问题讨论】: