问题描述
首先,我知道有很多关于这个话题的问题.我搜索了整个互联网,但大多数教程都是关于旧版本的 AdMob.此外,对于这个问题,所有人都有某种不同的解决方案.它们都不适合我.我非常接近将这些测试添加到我的应用程序中.他们只是没有出现.我收到以下错误:
First of all, I know there are a lot of questions about this topic. I searched all over the internet, but most of the tutorials are about older versions of AdMob. Also, all have some kind of different solution for the problem. They all do not work for me. I am very very close to getting these test adds into my application. They just don't show up. I get the following errors:
02-21 21:05:46.457: W/webcore(14924): 在第一次布局后无法获得 viewWidth
02-21 21:05:46.457: W/webcore(14924): Can't get the viewWidth after the first layout
02-21 21:05:46.586:W/Ads(14924):无效的未知请求错误:无法确定请求类型.您的广告单元 ID 是否正确?
02-21 21:05:46.586: W/Ads(14924): Invalid unknown request error: Cannot determine request type. Is your ad unit id correct?
02-21 21:05:46.586: D/webviewglue(14924): nativeDestroy 视图: 0x685300
02-21 21:05:46.586: D/webviewglue(14924): nativeDestroy view: 0x685300
02-21 21:05:46.586:I/Ads(14924):onFailedToReceiveAd(无效的 Google 广告请求.)
02-21 21:05:46.586: I/Ads(14924): onFailedToReceiveAd(Invalid Google Ad request.)
我还没有 AdMob 发布商 ID,因为这将是我投放市场的第一个 APP(我首先必须在市场上有一个 APP,然后才能获得该 APP 的 ID).我应该使用什么 ID?目前我有(在我的 Android 手机上测试):
I do not have a AdMob publisher ID yet, since this will be my first APP for the market (and I first have to have an APP on the market before I get an ID for the APP). What ID should I use? Currently I have (testing on my Android Phone):
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice("9B08CXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
//adRequest.addTestDevice("037c7xxxxxxxxxxx"); (Not right, is from console)
AdView adView = (AdView) this.findViewById(R.id.adView);
adView.loadAd(adRequest);
在我的 XML 中,我有(因为它还警告 viewWidth?).它被打包在一个更大的 LinearLayout 中:
In my XML, I have (because it also warns about viewWidth?). It is packed in a bigger LinearLayout:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="50dip">
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/admob_pub_id"/>
</LinearLayout>
我希望问题足够小,但仍然包含足够的信息.
I hope the question is small enough, but still contains enough information.
提前致谢!亲切的问候,乔斯.
Thanks in advance! Kinds regards, Jos.
我确实更改了清单文件(添加权限、活动 android:name=...、安卓:configChanges=...).我将 jar 添加到 lib 文件夹并将其添加到库中.
I do have the manifest file changed (add permissions, activity android:name=..., android:configChanges=...). I added the jar to a lib-folder and added it to the libraries.
推荐答案
您无需在市场上已有应用即可获取新应用的发布者 ID.在添加站点/应用程序"表单上的 Android 包 URL 字段中,只需输入market://details?id=your.package.name".您当然希望将your.package.name"替换为您应用的实际包名称.
You don't need to have an app already on the market to get a Publisher ID for a new app. In the Android Package URL field that's on the "Add Site/App" form, just enter "market://details?id=your.package.name". You'll of course want to replace the 'your.package.name' with your app's actual package name.
viewWidth 警告很好,在插入发布者 ID 后您可能仍会看到它们.
The viewWidth warnings are fine and you will likely still see them after inserting your Publisher ID.
这篇关于AdMob 4.3.1 添加不显示(还没有 AdMob ID(仅用于测试),无法获取 ViewWidth)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!