简体   繁体   English

Android Admob广告未展示

[英]Android Admob ads not showing

I newly created an admob account. 我新创建了一个admob帐户。 I ran a google provided example with my publisher Id, I found the following logs in the emulator logcat: 我用发布者ID运行了google提供的示例,我在模拟器logcat中找到以下日志:

I/Ads     (  564): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":1,"u_sd":1,"slotname":"**********","u_w":320,"msid":"com.hani.android.admobtest","simulator":1,"cap":"m,a","js":"afma-sdk-a-v4.3.1","isu":"B3EEABB8EE11C2BE770B684D95219ECB","cipa":0,"format":"320x50_mb","net":"ed","app_name":"1.android.com.hani.android.admobtest","hl":"en","extras":{"color_link":"0000FF","color_url":"00FF00","color_text":"000000","color_border":"000000","color_bg":"FF8855"},"u_h":480,"testing":1,"u_audio":4});</script></head><body></body></html>
W/webcore (  564): Can't get the viewWidth after the first layout
I/Ads     (  564): Received ad url: <"url": "http://googleads.g.doubleclick.net:80/mads/gma?preqs=1&u_sd=1&slotname=**********&u_w=320&msid=com.hani.android.admobtest&cap=m%2Ca&js=afma-sdk-a-v4.3.1&isu=B3EEABB8EE11C2BE770B684D95219ECB&cipa=0&format=320x50_mb&net=ed&app_name=1.android.com.hani.android.admobtest&hl=en&u_h=480&u_audio=4&u_so=p&adtest=on&output=html&region=mobile_app&u_tz=-180&ex=1&client_sdk=1&askip=1&pto=0&color_link=0000FF&color_url=00FF00&color_text=000000&color_border=000000&color_bg=FF8855&jsv=1", "afmaNotifyDt": "null">
D/dalvikvm(  564): GC_CONCURRENT freed 336K, 48% free 3280K/6279K, external 1651K/1996K, paused 6ms+5ms
I/Ads     (  564): Invalid response code: 404
D/webviewglue(  564): nativeDestroy view: 0x303a88
I/Ads     (  564): onFailedToReceiveAd(There was an internal error.)

and no ads are showing. 而且没有广告展示。 anybody faced that 404 error before ? 有人遇到过404错误吗?

here is my manifest xml 这是我的清单XML

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res/com.hani.titanium.test"
    package="com.hani.titanium.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".AdmobTestActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>
</manifest>

and the code 和代码

package com.hani.titanium.test; 包com.hani.titanium.test;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;

public class AdmobTestActivity extends Activity  {

     private AdView adView;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    adView = new AdView(this, AdSize.BANNER, "**********");
    LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
    layout.addView(adView);

    AdRequest request = new AdRequest();
//      request.addTestDevice(AdRequest.TEST_EMULATOR);
    request.setTesting(true);
    adView.loadAd(request);
    }

}

I tried both setTesting(true) and addTestDevice but none of them worked I also have project target = 13 我尝试了setTesting(true)addTestDevice但是它们都没有起作用,我也有project target = 13

for those who are familiar with Titanium I tried it there and got the same output which makes me belive it has something to do with admob service itself 对于那些熟悉Titanium的人,我在那里尝试过并获得了相同的输出,这使我相信它与admob服务本身有关

The code itself looks fine. 代码本身看起来不错。 Both setTesting(true) (which is deprecated FYI) and addTestDevice(AdRequest.TEST_EMULATOR will properly enable test mode on the emulator. Are you still seeing 404 errors? Do you have internet access on your device? setTesting(true) (已弃用的FYI)和addTestDevice(AdRequest.TEST_EMULATOR都将在模拟器上正确启用测试模式。您仍然看到404错误吗?您的设备可以上网吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM