AdMob 不会显示在我的应用中。每次我调用loadAd(..)
我收到以下错误:
请求资源 0x7f0b000e 失败,因为它很复杂。谷歌
找不到播放服务资源。检查您的项目配置以确保包含资源。
获取广告响应时出现问题。错误代码:1
我花了几个小时寻找这个问题的解决方案,但没有找到任何适合我的东西!我下载了最新版本的Google Play Services
并将它们添加为我的项目首选项中的库
这是我的代码:
活动:
public class WelcomeActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_welcome);
// Look up the AdView as a resource and load a request.
AdView adView = (AdView) this.findViewById(R.id.welcomeAdView);
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
adRequestBuilder.addTestDevice("************");
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
AdRequest adRequest = adRequestBuilder.build();
adView.loadAd(adRequest);
}
}
布局 XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/xx.xx"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="xx.xx.WelcomeActivity" >
.... other layout stuff .....
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true" >
<com.google.android.gms.ads.AdView
android:id="@+id/welcomeAdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="pub-***************" />
</RelativeLayout>
</RelativeLayout>
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xx.xx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="xx.xx.WelcomeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
... some more activities ...
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
</application>
</manifest>
我没有发现您的代码/布局有任何问题。问题可能出在Ads Unit Id
.
我建议你尝试创建一个不同的Ads Unit Id
希望它有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)