【发布时间】:2014-10-01 20:44:39
【问题描述】:
已解决:查看 cmets 如何修复错误。这是一个非常常见的问题,本主题将修复错误。为了证明解决方案有效,请查看我的免费应用程序中的广告:https://play.google.com/store/apps/details?id=com.colour.colourguessfree
在我开始之前,我知道这是一个常见问题,我花了一个晚上在 stackoverflow 上查看类似的主题,但无济于事。
我在使用 admob 和显示 adview 时遇到了很大的麻烦。在我的应用程序上,当它加载 adview 是内部状态的消息时:缺少必需的 XML 属性“adSize”。我已经尝试了许多方法来尝试解决这个问题,所以我觉得最好的方法是展示我希望有人能指出我正确的方向。
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.colourguessfree"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:theme="@style/NoActionBar">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name=".gameover" android:theme="@style/NoActionBar"
android:screenOrientation="portrait">
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
</application>
XML:
<?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:id="@+id/home"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
ads:adSize="BANNER"
ads:adUnitId="************"
ads:loadAdOnCreate="true" >
工作场所:
属性: 构建路径:
非常欢迎您提供帮助,我已经尝试了很多修复方法。一个清晰的指南会很棒!
更新:
这是我在 Google Play 服务迁移中尝试过的另一种方法。我试过的xml代码是:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY_AD_UNIT_ID"
ads:adSize="BANNER"/>
在 oncreate 中使用 java 代码为:
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);
但这会在 adview 中给出一个错误,说在 androidmanifest.xml 中缺少 android.configchanges 的 adactivity
更新 2
我完全迷失了,不确定它是否正常工作,日志似乎指向它一半工作主要问题是我根本看不到广告。
日志:
10-02 23:26:42.088: W/GooglePlayServicesUtil(5260): Google Play services is missing.
10-02 23:26:42.118: I/Ads(5260): Starting ad request.
10-02 23:26:42.158: I/Ads(5260): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
10-02 23:26:42.178: D/WebSettings(5260): mDataPath: /data/data/com.example.colourguessfree
10-02 23:26:42.208: D/WebSettings(5260): mDataPath: /data/data/com.example.colourguessfree
10-02 23:26:42.378: I/Adreno200-EGLSUB(5260): <ConfigWindowMatch:2081>: Format RGBA_8888.
10-02 23:26:42.388: D/memalloc(5260): /dev/pmem: Mapped buffer base:0x5228d000 size:3686400 offset:3072000 fd:82
10-02 23:26:42.588: D/memalloc(5260): /dev/pmem: Mapped buffer base:0x528d9000 size:7405568 offset:6791168 fd:85
10-02 23:26:43.178: W/GooglePlayServicesUtil(5260): Google Play services is missing.
10-02 23:26:43.178: E/GooglePlayServicesUtil(5260): GooglePlayServices not available due to error 1
10-02 23:26:43.208: W/GooglePlayServicesUtil(5260): Google Play services is missing.
10-02 23:26:43.208: E/GooglePlayServicesUtil(5260): GooglePlayServices not available due to error 1
10-02 23:26:43.238: W/dalvikvm(5260): VFY: unable to resolve virtual method 640: Landroid/net/ConnectivityManager;.isActiveNetworkMetered ()Z
10-02 23:26:43.288: D/WebSettings(5260): mDataPath: /data/data/com.example.colourguessfree
10-02 23:26:43.328: V/chromium(5260): external/chromium/net/host_resolver_helper/host_resolver_helper.cc:66: [1002/232643:INFO:host_resolver_helper.cc(66)] DNSPreResolver::Init got hostprovider:0x4cb15230
10-02 23:26:43.328: V/chromium(5260): external/chromium/net/base/host_resolver_impl.cc:1515: [1002/232643:INFO:host_resolver_impl.cc(1515)] HostResolverImpl::SetPreresolver preresolver:0x01aeba08
10-02 23:26:43.328: D/(5260): external/chromium/net/socket/tcp_fin_aggregation_factory.cc: libtcpfinaggr.so successfully loaded
10-02 23:26:43.328: D/(5260): external/chromium/net/socket/tcp_fin_aggregation_factory.cc,: TCP Fin Aggregation initializing method was found in libtcpfinaggr.so
10-02 23:26:43.328: D/TCPFinAggregation(5260): system property net.tcp.fin.aggregation was set
10-02 23:26:43.328: D/TCPFinAggregation(5260): system property net.tcp.fin.aggregation.wait was set, value: 20
10-02 23:26:43.328: D/TCPFinAggregation(5260): system property net.tcp.fin.aggregation.close was set, value: 300
10-02 23:26:43.328: D/TCPFinAggregation(5260): system property net.close.unused.sockets was set, value: 1
10-02 23:26:43.328: D/TCPFinAggregation(5260): Failed to get network status! received ret: -2
10-02 23:26:43.338: V/WebRequest(5260): WebRequest::WebRequest, setPriority = 1
10-02 23:26:43.348: V/chromium(5260): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:52: [1002/232643:INFO:hostres_plugin_bridge.cc(52)] StatHubCreateHostResPlugin initializing...
10-02 23:26:43.348: V/chromium(5260): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:57: [1002/232643:INFO:hostres_plugin_bridge.cc(57)] StatHubCreateHostResPlugin lib loaded
10-02 23:26:43.348: V/chromium(5260): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:63: [1002/232643:INFO:hostres_plugin_bridge.cc(63)] StatHubCreateHostResPlugin plugin connected
10-02 23:26:43.348: V/chromium(5260): external/chromium/net/http/http_cache.cc:1173: [1002/232643:INFO:http_cache.cc(1173)] HttpCache::OnBackendCreated HostStat created
10-02 23:26:43.348: E/chromium(5260): external/chromium/net/disk_cache/stat_hub.cc:190: [1002/232643:ERROR:stat_hub.cc(190)] StatHub::Init - App com.example.colourguessfree isn't supported.
10-02 23:26:43.348: E/chromium(5260): external/chromium/net/disk_cache/stat_hub.cc:190: [1002/232643:ERROR:stat_hub.cc(190)] StatHub::Init - App com.example.colourguessfree isn't supported.
10-02 23:26:43.498: W/Ads(5260): AdWebView unable to handle URL: http://192.168.1.254/mobile-step0.html?org_url=http://googleads.g.doubleclick.net%2fmads%2fstatic%2fmad%2fsdk%2fnative%2fsdk%2dcore%2dv40%2ehtml
10-02 23:26:43.578: E/Ads(5260): JS: Uncaught ReferenceError: AFMA_buildAdURL is not defined (null:1)
10-02 23:26:43.578: E/Web Console(5260): Uncaught ReferenceError: AFMA_buildAdURL is not defined at null:1
谷歌文档太烦人了,它经常提到他们不再支持的旧方法......
【问题讨论】:
-
我看不到任何关于修复的提及。但我可以看到您的路由器正在窃取 url 并将您重定向到其他内容:
10-02 23:26:43.498: W/Ads(5260): AdWebView unable to handle URL: http://192.168.1.254/mobile-step0.html?org_url=http://googleads.g.doubleclick.net%2fmads%2fstatic%2fmad%2fsdk%2fnative%2fsdk%2dcore%2dv40%2ehtml
标签: android admob google-play-services adview