AdMob ads appear ONLY in the emulator

微信扫一扫,分享到朋友圈

AdMob ads appear ONLY in the emulator

I would like to ask about android AdMob advertisements. I have created and finished android application adn then added the Admob Ads. Since then, ads only apear on emulator, but never on my phone(HTC desire s) screen. How is that possible and how to fix it?

Code:



    

    

    

    

    

    

Part from manifest code:









    
    
    
        
            

            
        
    

And this is java code:

package some.some.some;

import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends Activity {

Button button;
TextView tv1, tv2, tv3;
double a, b, c, d, e, f, g, h, i, j, l ,m ;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ...

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            tv1.setText("");
            tv2.setText("");
            tv3.setText("");
        }
    });

}

@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
    // TODO Auto-generated method stub
    super.onCreateOptionsMenu(menu);
    MenuInflater blowUp = getMenuInflater();
    blowUp.inflate(R.menu.menu, menu);
    return true;

}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
    case R.id.info:
        Intent i = new Intent("some.....");
        startActivity(i);
        break;
    case R.id.preferences:
        Intent p = new Intent("some.......");
        startActivity(p);
        break;
    case R.id.exit:
        finish();
        break;
    }
    return false;
}

}

P.S. My phone is HTC desire s; Android version 2.3.5; Emulator I am using is 4.2.2

05-31 18:31:33.974: I/HtcTextSelection(30023): (sendOnTextChanged)  stopTextSelectionMode
05-31 18:31:33.974: I/HtcTextSelection(30023): (sendOnTextChanged)  stopTextSelectionMode
05-31 18:31:33.994: I/HtcTextSelection(30023): (sendOnTextChanged)  stopTextSelectionMode
05-31 18:31:34.004: I/HtcTextSelection(30023): (sendOnTextChanged)  stopTextSelectionMode
05-31 18:31:34.004: I/HtcTextSelection(30023): (sendOnTextChanged)  stopTextSelectionMode
05-31 18:31:34.004: I/HtcTextSelection(30023): (sendOnTextChanged)  stopTextSelectionMode
05-31 18:31:34.294: D/Database(30023): dbopen(): path = /data/data/com.quad.equa/databases/webview.db, flag = 6, file size = 15360
05-31 18:31:34.324: D/Database(30023): dbopen(): path = /data/data/com.quad.equa/databases/webview.db, mode: wal, disk free size: 700 M, handle: 0x376840
05-31 18:31:34.364: D/Database(30023): dbopen(): path = /data/data/com.quad.equa/databases/webviewCache.db, flag = 6, file size = 6144
05-31 18:31:34.374: I/Database(30023): sqlite returned: error code = 0, msg = Recovered 6 frames from WAL file /data/data/com.quad.equa/databases/webviewCache.db-wal
05-31 18:31:34.374: D/Database(30023): dbopen(): path = /data/data/com.quad.equa/databases/webviewCache.db, mode: wal, disk free size: 700 M, handle: 0x3866f0
05-31 18:31:34.394: D/skia(30023): htcFlashPlugin::htcFlashPlugin
05-31 18:31:34.404: D/qct(30023): [RequestQueue.ActivePool.ActivePool] >> Enable Shutdown = true
05-31 18:31:34.404: D/qct(30023): [IdleCache.IdleCache] >> IDLE_CACHE_MAX = 40
05-31 18:31:34.524: D/qct(30023): [WebView.WebView] >> Enable Shutdown = true
05-31 18:31:34.524: D/skia(30023): htcFlashPlugin::htcFlashPlugin
05-31 18:31:34.534: D/qct(30023): [WebView.WebView] >> Enable Shutdown = true
05-31 18:31:34.754: D/dalvikvm(30023): GC_CONCURRENT freed 235K, 42% free 3319K/5639K, external 0K/0K, paused 11ms+12ms
05-31 18:31:34.854: D/skia(30023): htcFlashPlugin::htcFlashPlugin
05-31 18:31:34.854: E/ActivityThread(30023): Failed to find provider info for com.google.plus.platform
05-31 18:31:34.864: D/qct(30023): [WebView.WebView] >> Enable Shutdown = true
05-31 18:31:34.864: W/Ads(30023): loadAd called while the ad is already loading, so aborting.
05-31 18:31:34.874: D/ATRecorder(30023): com.htc.autotest.dlib.RecordEngine in loader [email protected]
05-31 18:31:34.874: D/WindowManagerImpl(30023): addView, new view, mViews[0]: [email protected]
05-31 18:31:34.884: I/Ads(30023): To get test ads on this device, call adRequest.addTestDevice("9B33F819BBF6446C23116F898BCD7877");
05-31 18:31:34.974: I/HtcTextSelection(30023): (onFocusChanged) focused =true
05-31 18:31:34.984: I/HtcTextSelection(30023): (onFocusChanged) stopTextSelectionMode
05-31 18:31:34.984: I/HtcTextSelection(30023): (onFocusChanged) dismissQuickAction
05-31 18:31:34.984: I/HtcTextSelection(30023): (onFocusChanged) mIsInTextSelectionMode = false
05-31 18:31:35.034: D/dalvikvm(30023): DexOpt: --- BEGIN 'ads-2141571499.jar' (bootstrap=0) ---
05-31 18:31:35.323: D/dalvikvm(30023): DexOpt: --- END 'ads-2141571499.jar' (success) ---
05-31 18:31:35.323: D/dalvikvm(30023): DEX prep '/data/data/com.quad.equa/cache/ads-2141571499.jar': unzip in 0ms, rewrite 290ms
05-31 18:31:35.573: I/Ads(30023): adRequestUrlHtml: AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"10718683671789989957","u_sd":1.5,"seq_num":"1","slotname":"a15191411a98286","u_w":320,"msid":"com.quad.equa","js":"afma-sdk-a-v6.4.1","ms":"wJ-iV8c0M8aPxLjIDF2tiuydOAZtgucqOYxrH_rC_il4R8ukh8guYElD8Q6K1aTcVovIgCrTMbs93UHN2CW6WylrvhcItIsZNxBM9MBo6gAHC41ufRI-xrkDBBjl10-m0moCTnRWUlznfnHK3nFPxUGvJ70kE0lCWfZZ7PNLahIqa8o6q6Kf5I8Bktln7v7G2ZXr0pEbeWZjf1XVA8yd0_rUBJmc1Yn8CQ-ke5qm4Kuqchhj-s2_roY9qkNjRjmniZfiPtBkQrfPnbtJbsdQu-P9r3LtXcwgSMP4OnZODWuqu6BvO2o7TqV3GdBKVghaPRgDMhiolK7aMfWNBgG24g","mv":"80210006.com.android.vending","isu":"9B33F819BBF6446C23116F898BCD7877","bas_off":0,"format":"320x50_mb","oar":0,"net":"wi","app_name":"3.android.com.quad.equa","hl":"lt","ad_pos":{"height":0,"visible":1,"y":573,"x":0,"width":480},"gnt":8,"u_h":533,"pt":1,"carrier":"24602","bas_on":0,"ptime":0,"u_audio":1});
05-31 18:31:35.703: D/webkit-timers(30023): [JWebCoreJavaBridge::resume] >> do resume
05-31 18:31:36.303: D/dalvikvm(30023): GC_CONCURRENT freed 266K, 40% free 3539K/5895K, external 0K/0K, paused 4ms+15ms
05-31 18:31:36.673: W/webcore(30023): Can't get the viewWidth after the first layout
05-31 18:31:36.793: I/Ads(30023): Received ad url: 
05-31 18:31:36.873: I/Ads(30023): Ad url modified to http://googleads.g.doubleclick.net:80/mads/gma?preqs=0&session_id=10718683671789989957&u_sd=1.5&seq_num=1&u_w=320&msid=com.quad.equa&js=afma-sdk-a-v6.4.1&ms=wJ-iV8c0M8aPxLjIDF2tiuydOAZtgucqOYxrH_rC_il4R8ukh8guYElD8Q6K1aTcVovIgCrTMbs93UHN2CW6WylrvhcItIsZNxBM9MBo6gAHC41ufRI-xrkDBBjl10-m0moCTnRWUlznfnHK3nFPxUGvJ70kE0lCWfZZ7PNLahIqa8o6q6Kf5I8Bktln7v7G2ZXr0pEbeWZjf1XVA8yd0_rUBJmc1Yn8CQ-ke5qm4Kuqchhj-s2_roY9qkNjRjmniZfiPtBkQrfPnbtJbsdQu-P9r3LtXcwgSMP4OnZODWuqu6BvO2o7TqV3GdBKVghaPRgDMhiolK7aMfWNBgG24g&mv=80210006.com.android.vending&isu=9B33F819BBF6446C23116F898BCD7877&bas_off=0&format=320x50_mb&oar=0&net=wi&app_name=3.android.com.quad.equa&hl=lt&gnt=8&u_h=533&carrier=24602&bas_on=0&ptime=0&u_audio=1&u_so=p&imbf=8009&output=html&region=mobile_app&u_tz=180&client_sdk=1&ex=1&slotname=a15191411a98286&gsb=wi&caps=interactiveVideo_th_autoplay_mediation_sdkAdmobApiForAds_di&jsv=48
05-31 18:31:36.873: I/Ads(30023): Request scenario: Online server request.
05-31 18:31:36.963: E/Ads(30023): IOException connecting to ad url.
05-31 18:31:36.963: I/Ads(30023): The following was caught and handled:
05-31 18:31:36.963: I/Ads(30023): java.net.ConnectException: googleads.g.doubleclick.net/127.0.0.1:80 - Connection refused
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:210)
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:440)
05-31 18:31:36.963: I/Ads(30023):   at java.net.Socket.connect(Socket.java:1013)
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:75)
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:48)
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
05-31 18:31:36.963: I/Ads(30023):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)
05-31 18:31:36.963: I/Ads(30023):   at com.google.ads.internal.f.b(SourceFile:489)
05-31 18:31:36.963: I/Ads(30023):   at com.google.ads.internal.f.run(SourceFile:460)
05-31 18:31:36.963: I/Ads(30023):   at java.lang.Thread.run(Thread.java:1027)
05-31 18:31:36.963: D/webviewglue(30023): nativeDestroy view: 0x34b118
05-31 18:31:37.172: W/dalvikvm(30023): JNI: DeleteGlobalRef(0xde5b9dc7) failed to find entry (valid=0)
05-31 18:31:37.172: W/dalvikvm(30023): JNI: DeleteGlobalRef(0xde5b9da7) failed to find entry (valid=0)
05-31 18:31:37.172: I/Ads(30023): onFailedToReceiveAd(A network error occurred.)

Add Following Code in the OnCreate Method,it works for me

AdView adview = (AdView)findViewById(R.id.adView);
AdRequest re = new AdRequest();
re.setTesting(true);
adview.loadAd(re);

微信扫一扫,分享到朋友圈

AdMob ads appear ONLY in the emulator

No breakpoint is reached with Geddy

上一篇

ov笑了!三星中端新机入网:首用刘海屏,指纹位置上天?

下一篇

你也可能喜欢

AdMob ads appear ONLY in the emulator

长按储存图像,分享给朋友