java - AdMob 在布局中占用空间,但实际上没有广告出现?

标签 java android xml admob

首先 - 自昨晚以来,我一直在通读各种问题。据我所知,我所做的一切都是正确的,并尝试了其他一切。

我已将 AdView 元素的背景颜色设置为 #000000,并且在正确的位置出现了一个具有适当尺寸的黑色矩形。
我 99% 肯定它有足够的空间。

XML:

<com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="xxxxxxxxxxxxxxxxxxxxx"
            android:visibility="visible"
            android:background="#000000" >
        </com.google.android.gms.ads.AdView>

java :

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

LogCat:(根据 google API/docs 可以忽略未找到的 Google Play 服务)

06-04 13:11:41.070: E/ResourceType(4968): 0x5acad0d8: Failed to ResTable::remove() cookie = 0x3, not last table. mHeaders.size() = 4. Warning for spontaneous crashes when the garbage collector runs.
06-04 13:11:41.070: E/asset(4968): Error removing runtime skin resource (cookie 0x3)
06-04 13:11:41.070: I/asset(4968): Problem removing all runtime skin resources
06-04 13:11:51.031: D/dalvikvm(4968): DexOpt: --- BEGIN 'ads-1359089110.jar' (bootstrap=0) ---
06-04 13:11:53.173: D/dalvikvm(4968): DexOpt: --- END 'ads-1359089110.jar' (success) ---
06-04 13:11:53.173: D/dalvikvm(4968): DEX prep '/data/data/lqf.liquidformula.converter/cache/ads-1359089110.jar': unzip in 0ms, rewrite 2147ms
06-04 13:11:53.223: I/Ads(4968): Use AdRequest.Builder.addTestDevice("BD0C01C19D6DD373FC42905822D0D2F3") to get test ads on this device.
06-04 13:11:53.233: I/Ads(4968): Starting ad request.
06-04 13:11:53.404: D/webcoreglue(4968): netstack: Memory Cache feature is ON
06-04 13:11:53.604: E/GooglePlayServicesUtil(4968): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
06-04 13:11:53.614: D/JSENGINE(4968): qualcomm.jsengine.version:C.2-patch35-git:7b7ad6f
06-04 13:11:54.815: D/libEGL(4968): loaded /vendor/lib/egl/libEGL_adreno.so
06-04 13:11:54.815: D/libEGL(4968): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
06-04 13:11:54.825: D/libEGL(4968): loaded /vendor/lib/egl/libGLESv2_adreno.so
06-04 13:11:54.845: I/Adreno-EGL(4968): <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build:  (CL4169980)
06-04 13:11:54.845: I/Adreno-EGL(4968): OpenGL ES Shader Compiler Version: 17.01.10.SPL
06-04 13:11:54.845: I/Adreno-EGL(4968): Build Date: 11/04/13 Mon
06-04 13:11:54.845: I/Adreno-EGL(4968): Local Branch: 
06-04 13:11:54.845: I/Adreno-EGL(4968): Remote Branch: 
06-04 13:11:54.845: I/Adreno-EGL(4968): Local Patches: 
06-04 13:11:54.845: I/Adreno-EGL(4968): Reconstruct Branch: 
06-04 13:11:54.875: D/HostStatisticManager(4968): netstack: DNS Host Prioritization is: ON, Version: 5.0.1
06-04 13:11:54.875: I/(4968): netstack: LIB_MGR - Lib loaded: libdnshostprio.so
06-04 13:11:54.875: I/(4968): netstack: STAT_HUB - Succeeded to load plugin: libdnshostprio.so
06-04 13:11:54.875: E/(4968): netstack: LIB_MGR - Error loading lib spl_proc_plugin.so
06-04 13:11:54.875: E/(4968): netstack: STAT_HUB - Failed to load plugin: spl_proc_plugin.so
06-04 13:11:54.885: I/(4968): netstack: LIB_MGR - Lib loaded: pp_proc_plugin.so
06-04 13:11:54.885: I/(4968): netstack: STAT_HUB - Succeeded to load plugin: pp_proc_plugin.so
06-04 13:11:54.885: E/(4968): netstack:  STAT_HUB - App lqf.liquidformula.converter isn't supported
06-04 13:11:54.905: D/OpenGLRenderer(4968): Enabling debug mode 0
06-04 13:11:55.456: I/dalvikvm(4968): Total arena pages for JIT: 11
06-04 13:11:55.456: I/dalvikvm(4968): Total arena pages for JIT: 12
06-04 13:11:55.456: I/dalvikvm(4968): Total arena pages for JIT: 13
06-04 13:11:55.456: E/GooglePlayServicesUtil(4968): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
06-04 13:11:55.466: E/GooglePlayServicesUtil(4968): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
06-04 13:12:00.161: V/chromium_net(4968): external/chromium/net/host_resolver_helper/host_resolver_helper.cc:66: [0604/131200:INFO:host_resolver_helper.cc(66)] DNSPreResolver::Init got hostprovider:0x6035400c
06-04 13:12:00.161: V/chromium_net(4968): external/chromium/net/base/host_resolver_impl.cc:1510: [0604/131200:INFO:host_resolver_impl.cc(1510)] HostResolverImpl::SetPreresolver preresolver:0x605da740
06-04 13:12:00.171: I/QCNEA(4968): |CAC| CAS is enabled
06-04 13:12:00.171: I/QCNEA(4968): |CAC| [CNE CLIENT STATE MACHINE] transition NOT_CONNECTED_NOT_ATTEMPTED -> CONNECTING
06-04 13:12:00.171: D/QCNEA(4968): |CAC| Connected to server socket: 86
06-04 13:12:00.171: I/QCNEA(4968): |CAC| [CNE CLIENT STATE MACHINE] transition CONNECTING -> CONNECTED_PENDING_PERM_RESPONSE
06-04 13:12:00.171: D/QCNEA(4968): |CAC| In monitor thread, performing select
06-04 13:12:00.171: D/QCNEA(4968): |CAC| readCallback: read len:12, ret:0, errno:0
06-04 13:12:00.171: I/QCNEA(4968): |CAC| [CNE CLIENT STATE MACHINE] transition CONNECTED_PENDING_PERM_RESPONSE -> NOT_CONNECTED_ACCESS_DENIED
06-04 13:12:00.171: I/QCNEA(4968): |CAC| client permission denied.
06-04 13:12:00.171: D/netstack(4968): netstack: Request Priority is ON
06-04 13:12:00.171: D/QCNEA(4968): |CAC| readCallback: read len:0, ret:0, errno:0
06-04 13:12:00.171: E/QCNEA(4968): |CAC| readCallback: end of stream
06-04 13:12:00.171: V/QCNEA(4968): |CAC| Dispatching Latency Service Status Update [status:SERVICE_STOPPED]
06-04 13:12:00.171: V/QCNEA(4968): |CAC| Dispatching Bitrate Service Status Update [status:SERVICE_STOPPED]
06-04 13:12:00.171: V/QCNEA(4968): |CAC| Clients reset
06-04 13:12:00.171: D/QCNEA(4968): |CAC| Monitor loop is terminating
06-04 13:12:00.171: D/(4968): external/chromium/net/socket/tcp_fin_aggregation_factory.cc: libtcpfinaggr.so successfully loaded
06-04 13:12:00.171: D/(4968): external/chromium/net/socket/tcp_fin_aggregation_factory.cc,: TCP Fin Aggregation initializing method was found in libtcpfinaggr.so
06-04 13:12:00.171: D/TCPFinAggregation(4968): netstack: TCPFinAggregation is 1, Version 5.0.1
06-04 13:12:00.171: D/TCPFinAggregation(4968): system property net.tcp.fin.aggregation.wait was set, value: 20
06-04 13:12:00.171: D/TCPFinAggregation(4968): system property net.tcp.fin.aggregation.close was set, value: 300
06-04 13:12:00.171: D/TCPFinAggregation(4968): netstack: CloseUnusedSockets is ON, (TCPFinAggregation), Version 5.0.1
06-04 13:12:00.171: D/TCPFinAggregation(4968): Failed to get network status! received ret: -6
06-04 13:12:00.171: D/Socket_Pool(4968): netstack: CloseUnusedSockets is ON
06-04 13:12:00.171: D/Socket_Pool(4968): netstack: system net.statistics value: 0
06-04 13:12:00.171: D/Socket_Pool(4968): netstack: CloseUnusedSockets is ON
06-04 13:12:00.171: D/Socket_Pool(4968): netstack: system net.statistics value: 0
06-04 13:12:00.171: D/(4968): external/chromium/net/http/http_getzip_factory.cc: libgetzip.so successfully loaded
06-04 13:12:00.171: D/(4968): external/chromium/net/http/http_getzip_factory.cc,: GETzip initializing method was found in libgetzip.so
06-04 13:12:00.171: D/(4968): netstack: Getzip is: ON, Version: 5.0.1
06-04 13:12:00.701: D/(4968): netstack: Early Connections is: ON, Version: 5.0.1, Param: 3
06-04 13:12:00.761: I/qtaguid(4968): Failed write_ctrl(t 93 43735651975168 2358) res=-1 errno=1
06-04 13:12:00.761: I/qtaguid(4968): Tagging socket 93 with tag 27c700000000(10183) for uid 2358 failed errno=-1
06-04 13:12:00.761: I/qtaguid(4968): Failed write_ctrl(t 95 43735651975168 2358) res=-1 errno=1
06-04 13:12:00.761: I/qtaguid(4968): Tagging socket 95 with tag 27c700000000(10183) for uid 2358 failed errno=-1
06-04 13:12:00.761: I/qtaguid(4968): Failed write_ctrl(t 96 43735651975168 2358) res=-1 errno=1
06-04 13:12:00.761: I/qtaguid(4968): Tagging socket 96 with tag 27c700000000(10183) for uid 2358 failed errno=-1
06-04 13:12:01.012: I/Ads(4968): Scheduling ad refresh 60000 milliseconds from now.
06-04 13:12:01.012: I/Ads(4968): Ad finished loading.
06-04 13:12:10.882: I/qtaguid(4968): Failed write_ctrl(u 95) res=-1 errno=22
06-04 13:12:10.882: I/qtaguid(4968): Untagging socket 95 failed errno=-22
06-04 13:12:10.882: I/qtaguid(4968): Failed write_ctrl(u 96) res=-1 errno=22
06-04 13:12:10.882: I/qtaguid(4968): Untagging socket 96 failed errno=-22

As you can see?

最佳答案

you have to change your layout as follows,

 <LinearLayout
        android:id="@+id/lladv"
        android:layout_alignParentBottom="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

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

关于java - AdMob 在布局中占用空间,但实际上没有广告出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24046660/

相关文章:

java - 进程被终止后 R.java 中的 Android NoSuchField 错误

android - 使用 getSherlockActivity() 或 getActivity() 或其他?

java - 滚动屏幕位图,在 SurfaceView 上向下一行不起作用

java - 合并两个 ContentView

java - SAX 解析器;读取特殊字符时出现错误

java - 在这种情况下如何正确调用构造函数?

Java+MongoDB 托管

java - 使用预先附加的附件启动用户的标准邮件客户端

xml - Golang 解析带有同名嵌套节点的 XML?

java - java中如何解码URL实体?