相关疑难解决方法(0)

Android:AdMob无法正常工作

AdMob不会在我的应用中显示.每次我调用时loadAd(..)都会出现以下错误:

请求资源0x7f0b000e失败,因为它很复杂.找不到Google Play服务资源.检查项目配置以确保包含资源.获得广告响应时出现问题.ErrorCode: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);
    }
Run Code Online (Sandbox Code Playgroud)

}

布局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" …
Run Code Online (Sandbox Code Playgroud)

android admob google-play-services

10
推荐指数
1
解决办法
2万
查看次数

标签 统计

admob ×1

android ×1

google-play-services ×1