Android:AdMob无法使用

前端之家收集整理的这篇文章主要介绍了Android:AdMob无法使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
AdMob不会显示在我的应用程序中每次我调用loadAd(..)我得到以下错误

Requesting resource 0x7f0b000e Failed because it is complex. The Google
Play services resources were not found. Check your project configuration to ensure that the resources are included.
There was a problem getting an ad response. ErrorCode: 1

搜索了几个小时解决这个问题,但没有找到任何适用于我的东西!我下载了最新版本的Google Play Services,并将其作为图书馆添加到我的项目首选项中

这是我的代码
活动:

@H_301_13@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:

@H_301_13@<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中:

@H_301_13@<?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>

解决方法

我的代码/布局没有发现任何问题.问题可以是广告单元ID.

建议您尝试创建不同的广告单元ID

希望它有效

猜你在找的Android相关文章