我是admob的新手,我正在努力让Sample广告适用于示例活动,但是当我构建它时,它只是出现了一个空白屏幕?是的我已将我的admob id添加到字符串中并将google-play-services_lib添加到库属性并且log cat给了我这些错误
2-25 16:48:37.218: E/GooglePlayServicesUtil(25818): The Google Play services resources
were not found. Check your project configuration to ensure that the resources are
included.
02-25 16:48:37.218: E/GooglePlayServicesUtil(25818): The Google Play services resources
were not found. Check your project configuration to ensure that the resources are
included.
02-25 16:49:06.683: E/SQLiteLog(25818): (14) cannot open file at line 30241 of
[00bb9c9ce4]
02-25 16:49:06.683: E/SQLiteLog(25818): (14) os_unix.c:30241: (2) open(/FileSyetmQuota.db)
02-25 16:49:06.683: D/WebKit(25818): ERROR:
02-25 16:49:06.683: D/WebKit(25818): SQLite database failed to load from
/FileSyetmQuota.db
02-25 16:49:06.683: D/WebKit(25818): Cause - unable to open database file
02-25 16:49:06.683: D/WebKit(25818):
external/webkit/Source/WebCore/platform/sql/SQLiteDatabase.cpp(71) : bool
WebCore::SQLiteDatabase::open(const WTF::String&, bool)
02-25 16:49:06.683: E/SQLiteLog(25818): (14) cannot open file at line 30241 of
[00bb9c9ce4]
02-25 16:49:06.683: E/SQLiteLog(25818): (14) os_unix.c:30241: (2)
open(/NotificationPermissions.db) -
02-25 16:49:06.683: D/WebKit(25818): ERROR:
02-25 16:49:06.683: D/WebKit(25818): SQLite database failed to load from
/NotificationPermissions.db
02-25 16:49:06.683: D/WebKit(25818): Cause - unable to open database file
02-25 16:49:06.683: D/WebKit(25818):
external/webkit/Source/WebCore/platform/sql/SQLiteDatabase.cpp(71) : bool
WebCore::SQLiteDatabase::open(const WTF::String&, bool)
02-25 16:49:06.683: I/Ads(25818): Ad request cancelled.
02-25 16:49:06.688: E/webview(25818): removeForStylusPenEvent onDetachedFromWindow
02-25 16:49:06.688: E/webview(25818): removeForStylusPenEvent START
02-25 16:49:06.688: E/webview(25818): removeForStylusPenEvent END
继承清单
<?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|smal lestScreenSize"/>
</application>
</manifest>
答案 0 :(得分:0)
首先将 Google移动广告SDK 放入lib文件夹
在Admob上激活帐户后,您需要在帐户中配置一个应用程序。在该应用程序之后,Admob将为您提供包含admob.jar和工作示例的Admob Android SDK。
private void AdmobFooterInitialize(){
adView = new AdView(this, AdSize.SMART_BANNER, "Your_AdMobPUBLISHERID");
LinearLayout layout = (LinearLayout)findViewById(R.id.linear);
layout.addView(adView);
AdRequest request = new AdRequest();
request.addTestDevice("your device id"); // this for testing
request.setTesting(false);
adView.loadAd(request);
}
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
如何获取deviceId: -
final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String deviceid = tm.getDeviceId();