此问题已经过了3个星期了。它在删除两个第三方插件后开始发生,我认为不管是由于代码延迟还是其他原因,它都在帮助admob工作。上周,我从零开始重建了整个项目并使其工作得相当好,但它又重新启动了。我也将开发操作系统从Ubuntu更改为Win8以防万一,但也没有解决它。
我的感觉是,admob sdk正在失去查询网络的能力。该应用程序本身工作,并要求使用互联网的能力。因此,应用程序本身具有Internet权限。如果我要重新启动应用程序,有时它会工作,有时它不会。如果我将它置于测试模式,它应该始终有效,但我仍然会收到以下错误(以及在此会话期间的后续刷新):
07-14 12:21:12.600: I/Ads(13271): Request scenario: Offline with no buffered ads.
07-14 12:21:12.600: I/Ads(13271): Network is unavailable. Aborting ad request.
07-14 12:21:12.610: I/Ads(13271): onFailedToReceiveAd(A network error occurred.)
我注意到在Google SDK中修改了网址。我删除了一些结果,因为它包含了我不想分享的信息。
07-14 12:21:12.175: I/Ads(13271): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script>
07-14 12:21:12.585: I/Ads(13271): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?preqs=0&session_id=17668451291953494526
07-14 12:21:12.600: I/Ads(13271): Ad url modified to http://googleads.g.doubleclick.net:80/mads/gma?preqs=0&session_id=17668451291953494526&seq_num=1&u_w=360
我正在使用Admob 6.4.1,但我升级到6.4.1,因为我在6.3.1中得到了同样的东西。
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
package="com.atomicent.blazereader"
android:versionCode="27"
android:versionName="1.14" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity
android:name="com.atomicent.blazereader.BlazeReader"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
活动java文件:
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
super.appView.getSettings().setJavaScriptEnabled(true);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("file:///android_asset/www/index.html");
super.appView.addJavascriptInterface(new Object()
{
@Suppress
public void RateApp()
{
LoadPage(getString(R.string.blazeReaderLink));
return;
}
@Suppress
public void writeLog(String tag, String textBlock)
{
Log.i(tag, textBlock);
return;
}
@Suppress
public void setPageUrl(String url)
{
pageUrl = url;
return;
}
@Suppress
public void refreshPage(String url)
{
mGaTracker.sendView(url);
GAServiceManager.getInstance().dispatch();
return;
}
@Suppress
public void SendException(String exception)
{
mGaTracker.sendException(exception, false);
GAServiceManager.getInstance().dispatch();
return;
}
@Suppress
public void OpenInBrowser()
{
OpenBrowserAction();
return;
}
@Suppress
public void EmailFeedback()
{
SendFeedbackAction();
return;
}
@Suppress
public void RefreshApp()
{
RefreshAction();
return;
}
@Suppress
public void BlazeReaderPro()
{
LoadPage(getString(R.string.blazeReaderProLink));
return;
}
@Suppress
public void OtherAppsLink()
{
LoadPage(getString(R.string.otherAtomicAppsLink));
return;
}
@Suppress
public void BlazeFacebook()
{
BlazeReaderFacebookAction();
return;
}
@Suppress
public void LoadCompleted()
{
//doAdMob();
return;
}
@Suppress
public void shareInterface(String subject, String title, String textBlock)
{
mGaTracker.sendEvent("ui_action", "share", pageUrl, null);
GAServiceManager.getInstance().dispatch();
ShareIntent(getActivity(), subject, title, textBlock, "text/plain");
return;
}
},"MyAndroid");
mGaInstance = GoogleAnalytics.getInstance(this);
mGaTracker = mGaInstance.getTracker(getString(R.string.ga_trackingId));
mHandler.postDelayed(new Runnable() {
public void run() {
doAdMob();
}
}, 5000);
}
protected void doAdMob()
{
// Create the adView
AdSize adSize;
String screenType = getString(R.string.screen_type);
if(screenType.equals("1"))
{
adSize = AdSize.BANNER;
}
else if(screenType.equals("2"))
{
adSize = AdSize.IAB_BANNER;
}
else if(screenType.equals("3"))
{
adSize = AdSize.IAB_LEADERBOARD;
}
else
{
adSize = AdSize.BANNER;
}
AdView adView = new AdView(this, adSize, "pubID");
LinearLayout layout = super.root;
layout.addView(adView);
AdRequest request = new AdRequest();
request.addTestDevice("B00EF0D66CFCBE408653D4FFE7DF8C2A");
request.addTestDevice("9B556DEC8E1B587D9DE1910F4D8ECFDC");
adView.loadAd(request);
adView.setAdListener(this);
}
在代码AdView中,我删除了我的pubID,以便在此处发布它。非常需要一些帮助。这是怎么回事?有谁有这个问题?我已经在stackoverflow和其他地方阅读过关于此的每篇文章,但没有任何有效的方法。我也已经清理了几次这个项目。是否有一些设置可能会阻止admob查询网络?
答案 0 :(得分:0)
我了解到该问题是由于config.xml文件不正确造成的。无论出于何种原因,它都不再与我所拥有的项目兼容。我用作adob 100%工作基础的项目没有config.xml文件,因此没有任何冲突(至少从admob的角度来看)。
经过15次重新测试和0次失败后,我相信这是正确的解决方法。 config.xml文件应该是这样的:
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.origin.packagename"
versionCode="27"
version = "1.14">
<!-- versionCode is optional and Android only -->
<name>App Name</name>
<description>
An example for phonegap build docs.
</description>
<author href="http://www.url.com" email="email.com">
Author Name
</author>
<preference name="phonegap-version" value="2.9.0" />
<preference name="target-device" value="universal" />
<preference name="permissions" value="none"/>
<!-- to enable individual permissions use the following examples -->
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<access origin="*" />
</widget>