2013-07-14 41 views
0

现在已经过这个问题3个星期了。它在删除两个第三方插件后开始发生,我想不管是由于代码延迟还是其他原因,都有助于admob工作。上周,我从零开始重建了整个项目,并使其工作得很好,但已经重新开始。为了以防万一,我也将开发操作系统从Ubuntu更改为了Win8,但这也没有解决问题。PhoneGap + Android + AdMob =网络不可用?

我的感觉是,admob sdk正在失去查询网络的能力。该应用程序本身的作品,并需要使用互联网的能力。所以,应用程序本身具有互联网许可。如果我要重新启动应用程序,有时它会起作用,有时它不会。如果我把它在测试模式下,它应该永远工作,但(在本届会议期间和在随后的刷新)我仍然得到以下错误:

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.) 

我注意到,该网址在谷歌被修改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

我想,以前添加到这个星期我用科尔多瓦2.5。我本周使用科尔多瓦2.9,但尚未解决它。我也在使用Google Admob 6.4.1,但在本周之前也使用了6.3.1。目标SDK是4.2.2(17)。 –

+0

我从一个与admob一起作用100%的不同应用重建项目,并在设置备份之后,我发现问题似乎是被修改的广告(请参阅日志条目:广告网址修改为...)。新项目不这样做。思考? –

回答

0

我得知问题是由于config.xml文件不正确。无论出于何种原因,它都停止与我拥有的项目兼容。我用作admob工作100%的基础的项目没有config.xml文件,因此没有任何冲突(至少从admob的角度来看)。

经过15次retests和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>