我将 admob 放在应用程序中,并对其进行了测试,它在模拟器和广告显示中运行良好,但是当我尝试检查它是否在我的手机上运行时,广告不显示,并且我在 logcat 中收到以下错误消息:
06-02 10:30:58.405: W/Ads(6148): IOException connecting to ad url.
06-02 10:30:58.405: W/Ads(6148): java.net.ConnectException: failed to connect to googleads.g.doubleclick.net/127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused)
06-02 10:30:58.405: W/Ads(6148): at libcore.io.IoBridge.connect(IoBridge.java:114)
06-02 10:30:58.405: W/Ads(6148): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
06-02 10:30:58.405: W/Ads(6148): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
06-02 10:30:58.405: W/Ads(6148): at java.net.Socket.connect(Socket.java:842)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:77)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
06-02 10:30:58.405: W/Ads(6148): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
06-02 10:30:58.405: W/Ads(6148): at com.google.ads.internal.f.b(SourceFile:428)
06-02 10:30:58.405: W/Ads(6148): at com.google.ads.internal.f.run(SourceFile:399)
06-02 10:30:58.405: W/Ads(6148): at java.lang.Thread.run(Thread.java:856)
06-02 10:30:58.405: W/Ads(6148): Caused by: libcore.io.ErrnoException: connect failed:
..................
手机已连接到 wifi,并且互联网工作正常。
编辑:它不起作用的原因是因为我正在运行自定义 rom 并且它阻止了所有广告,解决方法是编辑主机文件并从中删除所有广告拦截!:)