AdMobs Banner: W/GooglePlayServicesUtil﹕ Google Play services is missing

∥☆過路亽.° 提交于 2019-12-25 14:48:41

问题


I used this to implement my AdMob Banners, however I am getting an error: W/GooglePlayServicesUtil﹕ Google Play services is missing.

I have already added the following line to the build.gradle :

compile 'com.google.android.gms:play-services-ads:8.4.0'

Here is my onCreate() method:

protected void onCreate(Bundle savedInstanceState){

    super.onCreate(savedInstanceState);

    AdView adView = new AdView(this);
    adView.setAdSize(AdSize.BANNER);
    adView.setAdUnitId(testBanner);

    RelativeLayout layout = new RelativeLayout(this);
    layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

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

    //fullscreen
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    //scale image
    Display display = getWindowManager().getDefaultDisplay();
    size = new Point();
    display.getSize(size);
    dispX = size.x;
    dispY = size.y;
    bg = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(
            getResources(), R.drawable.bg),dispX,dispY,true);
    ls = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(
            getResources(), R.drawable.losescreen),GamePanel.rescaleX(805),GamePanel.rescaleY(1105),true);
    Pb = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(
            getResources(), R.drawable.playbutton),GamePanel.rescaleX(242),GamePanel.rescaleY(242),true);

    View gamePanel = new GamePanel(this);

    RelativeLayout.LayoutParams adParams =
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
    adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);

    layout.addView(gamePanel);
    layout.addView(adView, adParams);


    mInterstitialAd = new InterstitialAd(this);
    setContentView(layout);
    contextOfApplication = getApplicationContext();

}

回答1:


Go into the SDK manager and download Google Play Services and, if you haven't already, Google Play Repository.

(http://jmsliu.com/2085/add-admob-with-google-play-service.html)

Thats it. That line in the gradle signifies nothing until you install this. To open the SDK manager:

(envyandroid.com)

Let me know if it worked after installing the Google Play Services. If it did, make sure to accept an answer. If you need more help, feel free to ask me any more questions!

Hope it helped! :-)



来源:https://stackoverflow.com/questions/34420435/admobs-banner-w-googleplayservicesutil-google-play-services-is-missing

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