I can't show AdMob banner in my application

Atlas91

I trying to implement the AdMob banner in my app but it not showing. I already used the banners and i use always same way.. I have a FrameLayout with the view. This FrameLayout is inside a LinearLayout;

<FrameLayout
        android:layout_margin="5dp"
        android:layout_width="wrap_content"         
        android:layout_height="wrap_content"      
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true" >
    <com.google.ads.AdView 
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="MyId"
        ads:adSize="BANNER"
        ads:loadAdsOnCreate="true"/>
    </FrameLayout>

this is the java part:

adview = (AdView) findViewById(R.id.adView);
        adview.loadAd(new AdRequest());

and in the manifest:

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

with all meta-data:

<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
Nana Ghartey

You are mixing things up. You are using both old and new api with GoogleAdMobAdsSdk-6.4.1.jar. You should stick to the new api (admob via google play services). Make sure you don't have the GoogleAdMobAdsSdk-6.4.1.jar in your project's /libs/ folder. Then, reference the google play services library within your project and make the following changes:

In your layout file, change:

  xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

 <com.google.ads.AdView 
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="MyId"
        ads:adSize="BANNER"
        ads:loadAdsOnCreate="true"/>

to:

 xmlns:ads="http://schemas.android.com/apk/res-auto"

 <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adUnitId="MY_AD_UNIT_ID"
        ads:adSize="BANNER"/>

In your java code, change:

import com.google.ads.AdRequest;
import com.google.ads.AdView;

adView.loadAd(new AdRequest());

to:

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

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

Just hit Ctrl + Shift + O to import to the right packages

You can also follow the official guide on migrating to the new admob here.

Make sure you use the google play services version 4 or later. You can check its manifest xml file for the versionCode. Thanks

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How can I setup a variable in the application_controller and have is show in my footer?

분류에서Dev

Cannot display AdMob banner

분류에서Dev

Can't run my web application on jetty

분류에서Dev

How can I find why system can not run my application?

분류에서Dev

I can't update my rails form

분류에서Dev

I can't display my table (codeigniter)

분류에서Dev

I can't exit my local network

분류에서Dev

Can I make some of my appointments not show up on the sidebar?

분류에서Dev

my model binding is working even If I didn't show it in html

분류에서Dev

Can't get iad/adMob to mediate on device

분류에서Dev

Can I transfer private data of my Android application to inspect?

분류에서Dev

How can I know if an application reads my hardware fingerprint?

분류에서Dev

How can I open website in my android application?

분류에서Dev

Android - How can i create a "black list" for the files of my application

분류에서Dev

Can I use all my RAM for application data?

분류에서Dev

I set my AWS keys and they show up in linux terminal, but Rails 4 app can't find them. Using aws-sdk and carrierwave-aws gems

분류에서Dev

I am unable to show just simple UIActionSheet in my application in IOS8 on real device

분류에서Dev

what can I do if an application doesn't recognize horizontal scrolling?

분류에서Dev

I can't pass Excel.Application as an object to a method

분류에서Dev

I can't pass Excel.Application as an object to a method

분류에서Dev

I can fetch my entities that I save only on the first launch. If I relaunch the app, I can't fetch my entities

분류에서Dev

Why can't I crash my system with a fork bomb?

분류에서Dev

Why can't I spoof Facebook with my own DNS server?

분류에서Dev

Why can't I restart my maia service?

분류에서Dev

I can't put my Login Form in the correct place

분류에서Dev

Why can't I create a new Thread with an instance of my class?

분류에서Dev

I can't call variables from my other page PHP

분류에서Dev

Why can't I compile USB Proxy on my Beaglebone?

분류에서Dev

Why can't I access my objects member variable?

Related 관련 기사

  1. 1

    How can I setup a variable in the application_controller and have is show in my footer?

  2. 2

    Cannot display AdMob banner

  3. 3

    Can't run my web application on jetty

  4. 4

    How can I find why system can not run my application?

  5. 5

    I can't update my rails form

  6. 6

    I can't display my table (codeigniter)

  7. 7

    I can't exit my local network

  8. 8

    Can I make some of my appointments not show up on the sidebar?

  9. 9

    my model binding is working even If I didn't show it in html

  10. 10

    Can't get iad/adMob to mediate on device

  11. 11

    Can I transfer private data of my Android application to inspect?

  12. 12

    How can I know if an application reads my hardware fingerprint?

  13. 13

    How can I open website in my android application?

  14. 14

    Android - How can i create a "black list" for the files of my application

  15. 15

    Can I use all my RAM for application data?

  16. 16

    I set my AWS keys and they show up in linux terminal, but Rails 4 app can't find them. Using aws-sdk and carrierwave-aws gems

  17. 17

    I am unable to show just simple UIActionSheet in my application in IOS8 on real device

  18. 18

    what can I do if an application doesn't recognize horizontal scrolling?

  19. 19

    I can't pass Excel.Application as an object to a method

  20. 20

    I can't pass Excel.Application as an object to a method

  21. 21

    I can fetch my entities that I save only on the first launch. If I relaunch the app, I can't fetch my entities

  22. 22

    Why can't I crash my system with a fork bomb?

  23. 23

    Why can't I spoof Facebook with my own DNS server?

  24. 24

    Why can't I restart my maia service?

  25. 25

    I can't put my Login Form in the correct place

  26. 26

    Why can't I create a new Thread with an instance of my class?

  27. 27

    I can't call variables from my other page PHP

  28. 28

    Why can't I compile USB Proxy on my Beaglebone?

  29. 29

    Why can't I access my objects member variable?

뜨겁다태그

보관