Uncaught ReferenceError: AFMA_getSdkConstants is not defined(未捕获的 ReferenceError:未定义 AFMA_getSdkConstants)
问题描述
我正在尝试将 AdMob 广告添加到我的 Android 应用程序,但每当我打开应该显示广告的活动时,我都会收到此错误:
I'm trying to add an AdMob ad to my android application but whenever I'm opening the activity that is supposed to display the ad I get this error:
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.)
我在谷歌或其他地方找不到关于这个问题的任何信息,我认为我没有做错任何事情.
I can't find anything on this problem on google or elsewhere and I don't think I'm doing anything wrong.
以防万一,这是我应该展示广告的 xml 片段:
Just in case, here is my xml snippet that is supposed to show the ad:
<?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>
当然,我为这个问题删除了所有 - 我认为 - 不必要的代码,但如果有必要看到它,我也会在这里发布.
Of course I took out all the - I think - unnecessary code for this problem but if it's necessary to see it I'll post it here as well.
我还取出了我的 AdMob UnitID,您可能已经猜到了,但我写在这里是为了避免缺少 UnitId.
I also took out my AdMob UnitID, you probably figured that out but I'm writing this here so that missing UnitId won't be an answer.
我的清单具有列出的正确权限:
android.permission.ACCESS_NETWORK_STATE
android.permission.INTERNET
My Manifest has the right permissions listed:
android.permission.ACCESS_NETWORK_STATE
android.permission.INTERNET
我还添加了正确的 configChanges 的 AdActivity
and i also have the AdActivity added with the right configChanges
推荐答案
我也遇到了这个错误,通过在单独的线程中加载广告解决了(在 ICS 中,您不允许在主线程中执行网络操作)
I had this error too and solved by loading the ad in separate thread (in ICS you're not allowed to perform network operation in the main thread)
(new Thread() {
public void run() {
Looper.prepare();
adView.loadAd(new AdRequest());
}
}).start();
这篇关于未捕获的 ReferenceError:未定义 AFMA_getSdkConstants的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:未捕获的 ReferenceError:未定义 AFMA_getSdkConstants
基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01