Adview not showing

473 views
Skip to first unread message

phil_b...@hotmail.co.uk

unread,
Oct 4, 2014, 5:21:08 PM10/4/14
to google-adm...@googlegroups.com
Hi so the past few days I have been trying to get my adview to work unsuccessfully, could someone help me out?

XML:
xmlns:app="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"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/buy"
    android:layout_marginTop="20dp"
    android:gravity="center"
    app:adSize="SMART_BANNER"
    app:adUnitId="ca-app-pub-7560983512682295/1130294765" >
</com.google.android.gms.ads.AdView>

JAVA:

this is in the oncreate:
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
   .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
   .addTestDevice("DE7145D96C89A9C8211E9D5EB70BC9D2")
   .build(); 
adView.loadAd(adRequest);

manifest:

xmlns:ads="http://schemas.android.com/apk/res-auto"
<uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <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"
             android:theme="@android:style/Theme.Translucent" />

Error Log:

10-04 22:19:19.775: I/Ads(11830): Ad is not visible. Not refreshing ad.
10-04 22:19:19.775: I/Ads(11830): Scheduling ad refresh 60000 milliseconds from now.
10-04 22:19:34.865: W/dalvikvm(11970): threadid=1: thread exiting with uncaught exception (group=0x40aea9f0)
10-04 22:19:34.865: E/AndroidRuntime(11970): FATAL EXCEPTION: main
10-04 22:19:34.865: E/AndroidRuntime(11970): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.os.Handler.dispatchMessage(Handler.java:99)
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.os.Looper.loop(Looper.java:137)
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-04 22:19:34.865: E/AndroidRuntime(11970): at java.lang.reflect.Method.invokeNative(Native Method)
10-04 22:19:34.865: E/AndroidRuntime(11970): at java.lang.reflect.Method.invoke(Method.java:511)
10-04 22:19:34.865: E/AndroidRuntime(11970): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
10-04 22:19:34.865: E/AndroidRuntime(11970): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
10-04 22:19:34.865: E/AndroidRuntime(11970): at dalvik.system.NativeStart.main(Native Method)
10-04 22:19:34.865: E/AndroidRuntime(11970): Caused by: java.lang.NullPointerException
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
10-04 22:19:34.865: E/AndroidRuntime(11970): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
10-04 22:19:34.865: E/AndroidRuntime(11970): ... 11 more
10-04 22:19:43.075: W/GooglePlayServicesUtil(12108): Google Play services is missing.
10-04 22:19:43.115: I/Ads(12108): Starting ad request.
10-04 22:19:43.155: D/WebSettings(12108): mDataPath: /data/data/com.example.colourguessfree
10-04 22:19:43.195: D/WebSettings(12108): mDataPath: /data/data/com.example.colourguessfree
10-04 22:19:43.385: I/Adreno200-EGLSUB(12108): <ConfigWindowMatch:2081>: Format RGBA_8888.
10-04 22:19:43.395: D/memalloc(12108): /dev/pmem: Mapped buffer base:0x53358000 size:5046272 offset:4431872 fd:85
10-04 22:19:43.535: D/memalloc(12108): /dev/pmem: Mapped buffer base:0x53a74000 size:6275072 offset:5660672 fd:88
10-04 22:19:43.825: W/GooglePlayServicesUtil(12108): Google Play services is missing.
10-04 22:19:43.825: E/GooglePlayServicesUtil(12108): GooglePlayServices not available due to error 1
10-04 22:19:43.865: W/GooglePlayServicesUtil(12108): Google Play services is missing.
10-04 22:19:43.865: E/GooglePlayServicesUtil(12108): GooglePlayServices not available due to error 1
10-04 22:19:43.885: W/dalvikvm(12108): VFY: unable to resolve virtual method 640: Landroid/net/ConnectivityManager;.isActiveNetworkMetered ()Z
10-04 22:19:43.925: D/WebSettings(12108): mDataPath: /data/data/com.example.colourguessfree
10-04 22:19:43.955: V/chromium(12108): external/chromium/net/host_resolver_helper/host_resolver_helper.cc:66: [1004/221943:INFO:host_resolver_helper.cc(66)] DNSPreResolver::Init got hostprovider:0x4cc4d230
10-04 22:19:43.955: V/chromium(12108): external/chromium/net/base/host_resolver_impl.cc:1515: [1004/221943:INFO:host_resolver_impl.cc(1515)] HostResolverImpl::SetPreresolver preresolver:0x01aadb30
10-04 22:19:43.955: D/(12108): external/chromium/net/socket/tcp_fin_aggregation_factory.cc: libtcpfinaggr.so successfully loaded
10-04 22:19:43.955: D/(12108): external/chromium/net/socket/tcp_fin_aggregation_factory.cc,: TCP Fin Aggregation initializing method was found in libtcpfinaggr.so
10-04 22:19:43.955: D/TCPFinAggregation(12108): system property net.tcp.fin.aggregation was set
10-04 22:19:43.955: D/TCPFinAggregation(12108): system property net.tcp.fin.aggregation.wait was set, value: 20
10-04 22:19:43.955: D/TCPFinAggregation(12108): system property net.tcp.fin.aggregation.close was set, value: 300
10-04 22:19:43.955: D/TCPFinAggregation(12108): system property net.close.unused.sockets was set, value: 1
10-04 22:19:43.955: D/TCPFinAggregation(12108): Failed to get network status! received ret: -2
10-04 22:19:43.965: V/WebRequest(12108): WebRequest::WebRequest, setPriority = 1
10-04 22:19:43.975: V/chromium(12108): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:52: [1004/221943:INFO:hostres_plugin_bridge.cc(52)] StatHubCreateHostResPlugin initializing...
10-04 22:19:43.975: V/chromium(12108): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:57: [1004/221943:INFO:hostres_plugin_bridge.cc(57)] StatHubCreateHostResPlugin lib loaded
10-04 22:19:43.975: V/chromium(12108): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:63: [1004/221943:INFO:hostres_plugin_bridge.cc(63)] StatHubCreateHostResPlugin plugin connected
10-04 22:19:43.975: V/chromium(12108): external/chromium/net/http/http_cache.cc:1173: [1004/221943:INFO:http_cache.cc(1173)] HttpCache::OnBackendCreated HostStat created
10-04 22:19:43.975: E/chromium(12108): external/chromium/net/disk_cache/stat_hub.cc:190: [1004/221943:ERROR:stat_hub.cc(190)] StatHub::Init - App com.example.colourguessfree isn't supported.
10-04 22:19:43.975: E/chromium(12108): external/chromium/net/disk_cache/stat_hub.cc:190: [1004/221943:ERROR:stat_hub.cc(190)] StatHub::Init - App com.example.colourguessfree isn't supported.
10-04 22:19:44.335: E/Ads(12108): JS: Uncaught ReferenceError: AFMA_buildAdURL is not defined (null:1)
10-04 22:19:44.335: E/Web Console(12108): Uncaught ReferenceError: AFMA_buildAdURL is not defined at null:1



Im really lost on what is wrong, every online resource I have check says what i am doing is correct

Agris Ausējs

unread,
Oct 5, 2014, 10:11:51 AM10/5/14
to google-adm...@googlegroups.com
Please visit https://developers.google.com/mobile-ads-sdk/docs/admob/android/banner for ad integration sample codes because right now you do it the wrong way.
If you integrate ads through xml (in layout file) the you don' t have to do the following:

       
AdView adView = (AdView)this.findViewById(R.id.adView);
       
AdRequest adRequest = new AdRequest.Builder()
   
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
   
.addTestDevice("DE7145D96C89A9C8211E9D5EB70BC9D2")
   
.build();
         
adView
.loadAd(adRequest);



Message has been deleted

phil_b...@hotmail.co.uk

unread,
Oct 5, 2014, 3:05:17 PM10/5/14
to google-adm...@googlegroups.com

Thank you for replying, I originally had my code like that a added the extra in an attempt to fix it. The main problem I see I have is The following classes could not be instantiated:
- com.google.android.gms.ads.AdView 

Amy Quispe (AdMob SDK Team)

unread,
Oct 6, 2014, 8:04:37 PM10/6/14
to google-adm...@googlegroups.com
It sounds like you're not including Google Play Services in your app correctly. Can you try following the instructions here?

Amy Quispe

Spencer

unread,
Dec 16, 2014, 10:35:45 PM12/16/14
to google-adm...@googlegroups.com
Dear Philip

Please check below things.
1. Did you install and add SDK named google-play-services_lib in your platform? 
2. Did you add permission like INTERNET and INTERNET-STATE?
3. Did you add code for activity and meta-data in manifest ?
4. Did you add AdView in XML?
5. Did you add call functions?   etc.

If you write your code in Eclipse Platform, Please check below App.
The Key words is "How to admob" in Play Store.
There will be "AdMob ads How to add in my App" :








spencer


2014년 10월 5일 일요일 오전 6시 21분 8초 UTC+9, Philip Bayston 님의 말:
Reply all
Reply to author
Forward
0 new messages