android webview admob不显示

android webview admob not displaying(android webview admob不显示)
本文介绍了android webview admob不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i want to use google adds at bottom of my page.. into the emulator it properly displays the add but in device it doesn't
it gives me..

07-20 06:16:24.931: WARN/webcore(4289): Can't get the viewWidth after the first layout
07-20 06:16:25.101: WARN/Ads(4289): Invalid unknown request error: Cannot determine request type. Is your ad unit id correct?
07-20 06:16:25.111: INFO/Ads(4289): onFailedToReceiveAd(Invalid Google Ad request.)
07-20 06:16:28.957: WARN/PowerManagerService(175): Timer 0x7->0x3|0x0
07-20 06:16:28.957: INFO/PowerManagerService(175): Ulight 7->3|0
07-20 06:16:30.351: WARN/InputManagerService(175): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4a43b8f8
07-20 06:16:45.961: WARN/PowerManagerService(175): Timer 0x3->0x1|0x0
07-20 06:16:45.961: INFO/PowerManagerService(175): Ulight 3->1|0

i cant understand what is the problem? the same code is properly running on the emulator but not in device my XML file is

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:id="@+id/rltvLayout"
    android:layout_height="fill_parent">

    <LinearLayout android:id="@+id/linearLayout1"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:orientation="vertical">
        <WebView android:id="@+id/webView" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:fitsSystemWindows="true"/>

        </LinearLayout>
        <LinearLayout android:layout_width="fill_parent"
 android:id="@+id/ad_layout"
 android:layout_height="wrap_content"
 android:gravity="bottom"
 android:layout_alignParentBottom="true"
 android:layout_alignBottom="@+id/home_layout">
 </LinearLayout>
            </RelativeLayout>

解决方案

i've use this in xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent" android:id="@+id/rltvLayout1"
    android:layout_height="fill_parent">
    <LinearLayout android:id="@+id/linearLayoutwebview"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:orientation="vertical">
        <WebView android:id="@+id/webView1"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:fitsSystemWindows="true" />
    </LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
        android:id="@+id/ad_layout" android:layout_height="wrap_content"
        android:gravity="bottom" android:layout_alignParentBottom="true"
        android:layout_alignBottom="@+id/home_layout">
        <com.google.ads.AdView android:layout_width="wrap_content"
            android:layout_height="wrap_content" ads:adUnitId="here put ID"
            ads:adSize="BANNER" android:id="@+id/adView" ads:refreshInterval="60" />

    </LinearLayout>
</RelativeLayout>

one more point i found is that
There are some changes to the way Admob works in version 4.1.0
1) Remove attrs.xml (or if you need it for your own custom attributes, remove the parts related to AdViews).

2) Change the namespace in your layout from xmlns:ads="http://schemas.android.com/apk/res/com.your.packagename" to xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" see more...

这篇关于android webview admob不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)