我試圖AdMob廣告添加到我的Android應用程序,但每當我打開那應該顯示廣告的活動我得到這個錯誤:未捕獲的ReferenceError:AFMA_getSdkConstants沒有定義
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不會是答案。
我的清單具有正確的權限上市:
android.permission.ACCESS_NETWORK_STATE
android.permission.INTERNET對
和我也有AdActivity添加合適的configChanges
從日誌看起來像你在6.0.1。我假設你擁有全部7個configChanges AdMob指定你的應用是否運行。你確定你的設備連接到互聯網嗎? –
是的,該設備連接到我家的wifi,這裏是我的配置變化:android:configChanges =「keyboard | keyboardHidden | orientation | screenLayout | uiMode | screenSize | smallestScreenSize」 – dr3minem
嗯,我很難過。這個設備是否特定?它在仿真器上工作嗎? –