gpt4 book ai didi

android - AdMob 横幅广告未展示

转载 作者:可可西里 更新时间:2023-11-01 18:43:51 26 4
gpt4 key购买 nike

我在我的应用程序中使用 admob,它工作正常,但突然停止显示广告。下面是我使用的代码:

mainActivity.xml:

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>

主 Activity .java

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

AdRequest adRequest = new AdRequest.Builder().build();

mAdView.loadAd(adRequest);

安卓 list :

 <uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />

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

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

<!--Include the AdActivity configChanges and theme. -->
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />

我遵循了 adMob 网站上的所有说明,正如我几天前所说的那样。

下面是来自 logcat 的几行可能与我的问题有关:

09-25 22:44:50.292: E/dalvikvm(18554): Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza

09-25 22:45:07.209: E/Ads(18554): JS: Uncaught ReferenceError: renderAd is not defined (https://googleads.g.doubleclick.net/mads/gma:1)
09-25 22:45:07.209: E/Web Console(18554): Uncaught ReferenceError: renderAd is not defined:1
09-25 22:45:07.209: E/Ads(18554): JS: Uncaught ReferenceError: onLoad is not defined (https://googleads.g.doubleclick.net/mads/gma:1)
09-25 22:45:07.209: E/Web Console(18554): Uncaught ReferenceError: onLoad is not defined:1

我反复收到以下警告,当我点击应该显示广告的空白区域时,它出现得更多

09-25 22:46:10.911: W/PicturePileLayerContent(18554): Warning: painting PicturePile without content!

这是用“广告”过滤的 logcat

09-25 23:39:25.948: I/Ads(28874): Starting ad request.
09-25 23:39:25.948: I/Ads(28874): Use AdRequest.Builder.addTestDevice("8FCD71CAAE776558876AAA9BA964245A") to get test ads on this device.

09-25 23:39:26.919: I/Ads(22050): App index is not enabled
09-25 23:39:30.432: E/Ads(28874): JS: Uncaught ReferenceError: renderAd is not defined (https://googleads.g.doubleclick.net/mads/gma:1)
09-25 23:39:30.442: E/Ads(28874): JS: Uncaught ReferenceError: onLoad is not defined (https://googleads.g.doubleclick.net/mads/gma:1)
09-25 23:39:30.442: I/Ads(28874): Scheduling ad refresh 60000 milliseconds from now.
09-25 23:39:30.472: I/Ads(28874): Ad finished loading.

我到处搜索解决方案,也查看了一些类似但没有一个对我有帮助。

最佳答案

使用下面的代码行

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

AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
.addTestDevice("AC98C820A50B4AD8A2106EDE96FB87D4") // My Galaxy Nexus test phone
.build();


mAdView.loadAd(request );

而不是使用这个

AdRequest adRequest = new AdRequest.Builder().build();

因为当您的应用程序准备好在 Google Play 商店发布时将使用这一行。

您可以用您的设备 ID 代替 "AC98C820A50B4AD8A2106EDE96FB87D4"。获取设备id的代码:

String android_id = Settings.Secure.getString(getContext().getContentResolver(),
Settings.Secure.ANDROID_ID);

请仔细阅读这些内容:

https://developers.google.com/admob/android/targeting#test_ads

https://developers.google.com/admob/android/quick-start

看到这个

enter image description here

enter image description here

关于android - AdMob 横幅广告未展示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32787487/

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