Android的AdMob的AD浏览报强制关闭 [英] Android admob adview force close

查看:176
本文介绍了Android的AdMob的AD浏览报强制关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的,包括我的应用程序的广告非常的第一次尝试。我已经阅读了在线文档和阅读逐字逐句地。现在,唯一的一部分,我不明白的是如何实际要求的广告,并把它添加到我的应用程序。

This is my very first attempt at including ads in my app. I have read the online documentation and read it word for word. Now, the only part I don't get is how to actually request ads and to add it into my app.

AdView adView = (AdView)findViewById(R.id.ad);

这似乎工作到目前为止好。 别的我做的只是强制关闭。 例如加入这一行:

That seems to work so far so good. Anything else I do will just force close. For example adding this line:

adView.setAdListener(this);

我已经实现AdListener的活动。

I have implemented AdListener to the Activity.

顺便说一句,当我在导入的类悬停:

By the way, when I hover over the imported classes:

import com.admob.android.ads.AdView;

或其他类似的类,它说:注意:此元素已没有连接来源,也不附加的Javadoc,因此没有Javadoc中可以发现

or other similar classes, it says: Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

那是应该是正确的?

推荐答案

这很难肯定地说,没有看到你的code和布局,但这里有一些事情你可能要检查:

It's tough to say for sure without seeing your code and your layout, but here are some things you might want to check:

1)AdMobActivity在您AndroidManifest声明:

1) The AdMobActivity is declared in your AndroidManifest:

<activity android:name="com.admob.android.ads.AdMobActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|keyboard|keyboardHidden" />

2)你要求INTERNET权限在AndroidManifest:

2) You request the INTERNET permission in your AndroidManifest:

<uses-permission android:name="android.permission.INTERNET" />

3)您attrs.xml文件中包含必要的样式:

3) Your attrs.xml file contains the necessary styles:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="com.admob.android.ads.AdView">
        <attr name="backgroundColor" format="color" />
        <attr name="primaryTextColor" format="color" />
        <attr name="secondaryTextColor" format="color" />
        <attr name="keywords" format="string" />
        <attr name="refreshInterval" format="integer" />
    </declare-styleable>
</resources>

4)你的AD浏览报包含在您的布局:

4) Your AdView is included in your layout:

<com.admob.android.ads.AdView
  android:id="@+id/ad"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  myapp:backgroundColor="#000000"
  myapp:primaryTextColor="#FFFFFF"
  myapp:secondaryTextColor="#CCCCCC"
/>

5)你的AD浏览报被正确发现:

5) Your AdView is being found properly:

AdView adView = (AdView)findViewById(R.id.ad);
if (adView == null) {
    Log.e(TAG, "AdView not found!");
}

这篇关于Android的AdMob的AD浏览报强制关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆