admob 连接被拒绝

admob connection refused(admob 连接被拒绝)

本文介绍了admob 连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm just getting started with adding admob to my android app and have started with using the banner essentials example that is available from the admob website. Here is the sample code.

public class BannerEssentials extends Activity{
  @Override
  public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Lookup R.layout.main
    LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);

    // Create the adView
    // Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
    AdView adView = new AdView(this, AdSize.BANNER, "a14da528179106a");

    // Add the adView to it
    layout.addView(adView);

    // Initiate a generic request to load it with an ad
    AdRequest request = new AdRequest();
    request.setTesting(true);

    adView.loadAd(request);            
  }
}

I've setup my account with admob and everything appears to be in place, when I look in my logCat I see the following connection refused error message for admob. Has anyone else experienced this problem and if so how did you resolve it? Thanks in advance for your help.

04-13 11:39:33.410: WARN/Ads(5662): java.net.ConnectException: r.admob.com/127.0.0.1:80 - Connection refused
04-13 11:39:33.410: WARN/Ads(5662):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:254)
04-13 11:39:33.410: WARN/Ads(5662):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:533)
04-13 11:39:33.410: WARN/Ads(5662):     at java.net.Socket.connect(Socket.java:1055)
04-13 11:39:33.410: WARN/Ads(5662):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:62)
04-13 11:39:33.410: WARN/Ads(5662):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:88)
04-13 11:39:33.410: WARN/Ads(5662):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHTTPConnection(HttpURLConnectionImpl.java:927)
04-13 11:39:33.410: WARN/Ads(5662):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:909)
04-13 11:39:33.410: WARN/Ads(5662):     at b.a(Unknown Source)
04-13 11:39:33.410: WARN/Ads(5662):     at b.doInBackground(Unknown Source)
04-13 11:39:33.410: WARN/Ads(5662):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-13 11:39:33.410: WARN/Ads(5662):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-13 11:39:33.410: WARN/Ads(5662):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-13 11:39:33.410: WARN/Ads(5662):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
04-13 11:39:33.410: WARN/Ads(5662):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
04-13 11:39:33.410: WARN/Ads(5662):     at java.lang.Thread.run(Thread.java:1096)

My Manifest file below.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.google.ads.example"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".BannerEssentials"
                  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"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-sdk android:minSdkVersion="3" />

</manifest> 

解决方案

How is your manifest set up? Did you add the Internet permission? Did you set the appropriate metadata parameters?

这篇关于admob 连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:admob 连接被拒绝

基础教程推荐