2013-07-14 44 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>