gpt4 book ai didi

Android - Admob 问题!

转载 作者:太空狗 更新时间:2023-10-29 16:25:12 26 4
gpt4 key购买 nike

所以我尝试使用 admob 向我的应用添加一个简单的广告。我已按照 SDK 的教程进行操作,但遇到了一个错误。

这是错误:

Multiple annotations found at this line:
- ERROR No resource identifier found for attribute 'secondaryTextColor' in package
'man.utd.headlines.man.utd'
- ERROR No resource identifier found for attribute 'primaryTextColor' in package 'man.utd.headlines.man.utd'
- ERROR No resource identifier found for attribute 'backgroundColor' in package 'man.utd.headlines.man.utd'

所以我认为这一定是我的包名有问题,但据我所知一切正常。

在我的布局文件中,我有以下内容:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines.man.utd"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

但包名似乎是正确的:

package man.utd.headlines.man.utd;

有什么想法吗?非常令人沮丧!

我也检查了我的 list 并尝试使用这个包名,但它仍然不起作用:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="man.utd.headlines"

非常感谢任何帮助。

更新:通过更改包名称使它们更加一致来解决 - 它们必须在主类和 list 中完全相同!

新问题:广告不会显示!

这是我的布局文件:

<?xml version="1.0" encoding="utf-8"?>

<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

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

有什么想法吗?非常感谢任何帮助:)。

最佳答案

您的 attrs.xml(在 res/values 文件夹中)文件是否如下所示:

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

如果没有,请在您的 res/values 文件夹中创建一个名为 attrs.xml 的 xml 文件,并将此代码复制到其中。

关于Android - Admob 问题!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3613767/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com