Google Play services resources were not found. 'AdsMob'

隐身守侯 提交于 2019-12-05 03:56:32

问题


I am getting this error when I try to load and InterstitialAd from google AdMob. I know that I have written the code correctly. As I followed the short tutorial on https://developers.google.com/mobile-ads-sdk/docs/admob/advanced#play

All the happens is I get and error in the Logcat. What might I be doing wrong.

Here is the code:

public class Pref extends PreferenceActivity implements
        SharedPreferences.OnSharedPreferenceChangeListener {

    /** The view to show the ad. */
      private AdView adView;

      /* Your ad unit id. Replace with your actual ad unit id. */
      private static final String AD_UNIT_ID = "MY_ID";
      private static final String inAD_UNIT_ID = "MY_ID";
      private InterstitialAd interstitial;


    @SuppressWarnings("deprecation")
    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.ad_layout);


        //addPreferencesFromResource(R.xml.preferences);
        //getPreferenceManager()
                //.setSharedPreferencesName("com.gordondev.south_korea");
        //addPreferencesFromResource(2130903040);
        //getPreferenceManager().getSharedPreferences()
            //  .registerOnSharedPreferenceChangeListener(this);

        // Create the interstitial.
        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId(inAD_UNIT_ID);

        // Create ad request.
        AdRequest adRequest = new AdRequest.Builder().build();

        // Begin loading your interstitial.
        interstitial.loadAd(adRequest);

        // Create an ad.
        adView = new AdView(this);
        adView.setAdSize(AdSize.BANNER);
        adView.setAdUnitId(AD_UNIT_ID);

        // Add the AdView to the view hierarchy. The view will have no size
        // until the ad is loaded.
        LinearLayout layout = (LinearLayout) findViewById(R.id.adview);
        layout.addView(adView);

        //((LinearLayout)view).addView(adView);

        // Create an ad request. Check logcat output for the hashed device ID to
        // get test ads on a physical device.
        AdRequest adRequest1 = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
            .build();

        // Start loading the ad in the background.
        adView.loadAd(adRequest1);


    }

    // Invoke displayInterstitial() when you are ready to display an interstitial.
      public void displayInterstitial() {
        if (interstitial.isLoaded()) {
          interstitial.show();
        }
      }

Here is the Logcat error:

03-13 16:49:41.565: I/Ads(29755): Use AdRequest.Builder.addTestDevice("099098AA8954CC0C01AD412143D81BDD") to get test ads on this device.
03-13 16:49:41.565: I/Ads(29755): Starting ad request.
03-13 16:49:41.575: E/GooglePlayServicesUtil(29755): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
03-13 16:49:41.575: I/Ads(29755): Use AdRequest.Builder.addTestDevice("099098AA8954CC0C01AD412143D81BDD") to get test ads on this device.
03-13 16:49:41.575: I/Ads(29755): Starting ad request.
03-13 16:49:41.585: E/GooglePlayServicesUtil(29755): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
03-13 16:49:41.625: E/GooglePlayServicesUtil(29755): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
03-13 16:49:41.635: E/GooglePlayServicesUtil(29755): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
03-13 16:49:41.645: E/GooglePlayServicesUtil(29755): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
03-13 16:49:41.645: E/GooglePlayServicesUtil(29755): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
03-13 16:49:42.365: I/Ads(29755): Ad finished loading.
03-13 16:49:43.085: I/Ads(29755): Scheduling ad refresh 60000 milliseconds from now.
03-13 16:49:43.085: I/Ads(29755): Ad finished loading.

回答1:


03-13 16:49:41.585: E/GooglePlayServicesUtil(29755): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

is a benign error. If the ads are showing don't worry about it. Your code looks fine.




回答2:


I have the same error running my apps on my device. It seems that the problem have to do with your device.Try using your app to another device

If the ads will appear, your code seems to be fine.

Also you can change this line to this:

AdRequest adRequest = new AdRequest.Builder().build();

Make sure that you have the correct google play libraries in your project

If you have done these : https://developers.google.com/mobile-ads-sdk/docs/ Your app ads should work perfectly



来源:https://stackoverflow.com/questions/22390787/google-play-services-resources-were-not-found-adsmob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!