2015-05-03 51 views
0

我試圖在我的應用程序中加載插頁式廣告,但未加載。我已經在我的應用程序中聲明瞭所有內容,但logcat說了另一個故事。未能加載請確保其聲明

這裏是logcat的

W/Ads  (24737): Could not find com.google.android.gms.ads.AdActivity, please make sure it is declared in AndroidManifest.xml 

I/iu.UploadsManager(13004): End new media; added: 0, uploading: 0, time: 134 ms 
I/iu.UploadsManager(13004): End new media; added: 0, uploading: 0, time: 69 ms 
I/dex2oat (25072): dex2oat took 20.680s (threads: 2) 
I/dex2oat (25184): /system/bin/dex2oat --runtime-arg -classpath --runtime-  arg --instruction-set=arm --instruction-set-features=div --runtime-arg - Xrelocate --boot-image=/system/framework/boot.art --dex- file=/data/data/com.tech.slidechat/cache/ads-489919204.jar --oat-fd=31 --oat-location=/data/data/com.tech.slidechat/cache/ads-489919204.dex --runtime-arg - Xms64m --runtime-arg -Xmx512m 
I/dex2oat (25184): dex2oat took 78.925ms (threads: 2) 
I/Ads  (25163): CsiReporterFactory: CSI is not enabled. No CSI reporter created. 
I/Ads  (25163): Starting ad request. 
I/Ads  (25163): Use AdRequest.Builder.addTestDevice("3DA69D7DC8C309681C9A4C6D3386B798") to get test ads on this device. 
I/Ads  (13004): CsiReporterFactory: CSI is not enabled. No CSI reporter created. 
I/Ads  (13004): CsiReporterFactory: CSI is not enabled. No CSI reporter created. 
I/chromium(13004): [INFO:CONSOLE(0)] "Creating Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0) 
I/chromium(13004): [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0) 
I/chromium(13004): [INFO:CONSOLE(0)] "Application Cache Downloading event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0) 
I/chromium(13004): [INFO:CONSOLE(0)] "Application Cache Progress event (0 of 1) https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.js", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0) 
I/chromium(13004): [INFO:CONSOLE(0)] "Application Cache Progress event (1 of 1) ", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0) 
I/chromium(13004): [INFO:CONSOLE(0)] "Application Cache Cached event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0) 
I/Ads  (25163): Ad finished loading. 
W/Ads  (25163): It is not recommended to show an interstitial before onAdLoaded completes. 
I/ActivityManager(669): START u0 {cmp=com.tech.slidechat/com.google.android.gms.ads.AdActivity (has extras)} from uid 10072 on display 0 
I/ActivityManager(669): Start proc com.tech.slidechat for activity com.tech.slidechat/com.google.android.gms.ads.AdActivity: pid=25337 uid=10072 gids={50072, 9997, 3003, 1028, 1015} abi=armeabi-v7a 
W/Ads  (25337): Could not get info for ad overlay. 

這裏是我的AndroidManifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.tech.example" > 

<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<application 
    android:allowBackup="true" 
    android:icon="@mipmap/google" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" 
    android:hardwareAccelerated="true" 
    > 
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> 
    <activity 
     android:launchMode="singleInstance" 
     android:alwaysRetainTaskState="true" 
     android:name=".MainActivity" 
     android:process=":remote" 
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
     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.android.gms.ads.AdActivity" 
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
     android:theme="@android:style/Theme.Translucent" /> 
</application> 

我的主要活動

public class MainActivity extends ActionBarActivity { 

    SlidingTabLayout tabs; 
    ViewPager viewPager; 
    TabsPagerAdapter adapter; 
    Toolbar toolbar; 
private InterstitialAd mInterstitialAd; 


CharSequence Titles[]={ "tab1", "tab2", "tab3" }; 
int Numboftabs =3; 

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    mInterstitialAd = new InterstitialAd(this); 
    mInterstitialAd.setAdUnitId(getString(R.string.ad_unit_id)); 
    AdRequest adRequest = new AdRequest.Builder() 
      .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
      .addTestDevice("AALUBHALU") 
      .build(); 
    mInterstitialAd.loadAd(adRequest); 



    toolbar = (Toolbar) findViewById(R.id.tool_bar); 
     setSupportActionBar(toolbar); 


    adapter = new TabsPagerAdapter(getSupportFragmentManager(), Titles, Numboftabs); 

    // Assigning ViewPager View and setting the adapter 
    viewPager = (ViewPager) findViewById(R.id.pager); 
    viewPager.setAdapter(adapter); 
    viewPager.setOffscreenPageLimit(2); 
    // Assiging the Sliding Tab Layout View 
    tabs = (SlidingTabLayout) findViewById(R.id.tabs); 
    tabs.setDistributeEvenly(true); 



    tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { 
     @Override 
     public int getIndicatorColor(int position) { 
      return getResources().getColor(R.color.tabsScrollColor); 
     } 

     @Override 
     public int getDividerColor(int i) { 
      return 0; 
     } 
    }); 

    tabs.setViewPager(viewPager); 
    // Prepare an Interstitial Ad Listener 
    mInterstitialAd.setAdListener(new AdListener() { 
     public void onAdLoaded() { 
      // Call displayInterstitial() function 
      displayInterstitial(); 
     } 
    }); 
} 
public void displayInterstitial() { 
    // If Ads are loaded, show Interstitial else show nothing. 
    if (mInterstitialAd.isLoaded()) { 
     mInterstitialAd.show(); 
    } 
} 



} 

ProGuard的規則

For Google Play Services 
-keep public class com.google.android.gms.ads.**{ 
public *; 
} 

For old ads classes 
-keep public class com.google.ads.**{ 
public *; 
} 

For mediation 
-keepattributes *Annotation* 

Other required classes for Google Play Services 
Read more at http://developer.android.com/google/play-services/setup.html 
-keep class * extends java.util.ListResourceBundle { 
protected Object[][] getContents(); 
} 

-keep public class  

com.google.android.gms.common.internal.safeparcel.SafeParcelable { 
public static final *** NULL; 
} 
-keep class * extends java.util.ListResourceBundle { 
protected Object[][] getContents(); 
} 

-keep public class 

com.google.android.gms.common.internal.safeparcel.SafeParcelable { 
public static final *** NULL; 
} 

-keepnames @com.google.android.gms.common.annotation.KeepName class * 
-keepclassmembernames class * { 
@com.google.android.gms.common.annotation.KeepName *; 
} 

-keepnames class * implements android.os.Parcelable { 
public static final ** CREATOR; 
} 

我不知道什麼是錯,請幫我找出答案。 謝謝。

回答

0

開始通過調用interstitial.show()在你的應用,而不是從onAdLoaded()自然破發點,否則你將提供一個extremeley不好的用戶體驗和最有可能讓您的AdMob帳戶被禁止。

您還沒有在關於AdActivity的警告之前包含任何日誌,並且您沒有在logcat中包含時間戳,因此很難準確判斷髮生了什麼。但首先確保上面的AndroidManifest實際上已經將它整合到APK中。

+0

裕做到這一點還,但結果是相同的,現在沒有得到有關體現任何警告,只有此錯誤仍然存​​在「無法獲取廣告疊加信息」是否需要在佈局中執行某些操作?我正在使用webview的片段。 – Rahul

+0

您使用的是插頁式廣告單元嗎? – William

+0

當然可以。現在發生了一些有趣的事情,廣告只出現在logcat上面的同一個錯誤並關閉了自己。我看不到哪個廣告正在加載,只是出現白屏,然後關閉。 – Rahul

2

ü應該作出這樣的清單:

<activity android:name="com.google.android.gms.ads.AdActivity" 
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
    android:theme="@android:style/Theme.Translucent" 
    android:process=":remote"/> 

AdActivity必須在同一個進程與主要活動

+1

我找到了更好的解決方案。 即在AdActivity中添加「android:multiprocess =」true「而不是」android:process「 – IRON

相關問題