gpt4 book ai didi

android - Uncaught ReferenceError : AFMA_getSdkConstants is not defined

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:48:42 25 4
gpt4 key购买 nike

我正在尝试将 AdMob 广告添加到我的 Android 应用程序,但每当我打开应该显示广告的 Activity 时,我都会收到此错误:

I/Ads(11448): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":4,"session_id":"17111845472336325405","u_sd":2,"seq_num":"5","slotname":"MYUSERIDHERE","u_w":360,"msid":"com.lazyprogrammer.dartscore","adtest":"on","js":"afma-sdk-a-v6.0.1","mv":"8011019.com.android.vending","isu":"70069487A7A68D24BEF2581104A73318","cipa":0,"format":"360x50_mb","net":"wi","smart_h":"auto","app_name":"1.android.com.lazyprogrammer.dartscore","hl":"en","smart_w":"full","u_h":613,"carrier":"26203","ptime":225498,"u_audio":1});</script></head><body></body></html>
E/Ads(11448): JS: Uncaught ReferenceError: AFMA_getSdkConstants is not defined (about:blank:1)
E/Web Console(11448): Uncaught ReferenceError: AFMA_getSdkConstants is not defined at about:blank:1
I/Ads(11448): AdLoader timed out after 60000ms while getting the URL.
D/webviewglue(11448): nativeDestroy view: 0x2bc958
I/Ads(11448): onFailedToReceiveAd(A network error occurred.)
I/Ads(11448): AdLoader timed out after 60000ms while getting the URL.
D/webviewglue(11448): nativeDestroy view: 0x5a1850
I/Ads(11448): onFailedToReceiveAd(A network error occurred.)

我在谷歌或其他地方找不到关于这个问题的任何信息,我不认为我做错了什么。

以防万一,这是我应该显示广告的 xml 代码段:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
...

<com.google.ads.AdView
android:id="@+id/adView"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="MyIDhere"
ads:loadAdOnCreate="true"
ads:testDevices="70069487A7A68D24BEF2581104A73318" />

</RelativeLayout>

当然,我删除了所有 - 我认为 - 这个问题不必要的代码,但如果有必要查看它,我也会在这里发布。

我还取出了我的 AdMob UnitID,您可能已经猜到了,但我写在这里是为了避免缺少 UnitId 的问题。

我的 list 列出了正确的权限:
android.permission.ACCESS_NETWORK_STATE
android.permission.INTERNET

我还为 AdActivity 添加了正确的 configChanges

最佳答案

我也有这个错误,通过在单独的线程中加载广告来解决(在 ICS 中,您不允许在主线程中执行网络操作)

(new Thread() {
public void run() {
Looper.prepare();
adView.loadAd(new AdRequest());
}
}).start();

关于android - Uncaught ReferenceError : AFMA_getSdkConstants is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10717358/

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