Java 加载失败。请确保其已声明

Java 加载失败。请确保其已声明,java,android,android-fragments,webview,admob,Java,Android,Android Fragments,Webview,Admob,我试图在我的应用程序中加载间隙广告,但它没有加载。我已经在我的应用程序中声明了所有内容,但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,

我试图在我的应用程序中加载间隙广告,但它没有加载。我已经在我的应用程序中声明了所有内容,但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>
前进规则

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;
 }
我不知道怎么了,请帮我查一下。
谢谢。

首先在应用程序中的自然断点处调用
interstival.show()
,而不是从
onAdLoaded()
,否则您将提供极差的用户体验,很可能会被禁止使用Admob帐户


在关于adactivity的警告之前,您还没有包括任何日志,并且您也没有在logcat中包括时间戳,因此很难确切地说出发生了什么。但是首先要确保上面的AndroidManifest已经完整地进入了您的APK中。

u应该这样制作清单:

<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必须与主活动处于相同的过程中

Yuh也完成了,但结果现在相同,没有收到任何关于清单的警告,只是此错误仍然存在“无法获取广告覆盖信息”布局中是否需要执行某些操作?我在片段中使用webview。你使用的是间隙adUnitId吗?是的,当然。现在发生了一些有趣的事情,这则广告出现了片刻,在logcat中给出了上面相同的错误,并自行关闭。我看不到哪个广告正在加载,只是出现了一个白色屏幕然后关闭。如果它被意外配置(在Admob中)为横幅广告,您可能会遇到这样的问题。不,问题肯定不是这样,即使测试广告也没有显示。我找到了更好的解决方案。即在AdActivity中添加“android:multiprocess=“true”,而不是“android:process”
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();
    }
}



}