Java AdMob-必需的XML属性。“adSize”不见了
嗨,我是android应用程序的新手。发展。所以我的错误可能看起来愚蠢可笑,对此我感到非常抱歉 无论如何 我一直在尝试将AdMob用于我的android应用程序。但我不能。在图形布局上,它显示必需的XML属性。adSize不见了。我看了其他话题,但到目前为止运气不好。 我的应用程序也不会再启动了。它总是崩溃 ActivityMain.xmlJava AdMob-必需的XML属性。“adSize”不见了,java,android,xml,admob,Java,Android,Xml,Admob,嗨,我是android应用程序的新手。发展。所以我的错误可能看起来愚蠢可笑,对此我感到非常抱歉 无论如何 我一直在尝试将AdMob用于我的android应用程序。但我不能。在图形布局上,它显示必需的XML属性。adSize不见了。我看了其他话题,但到目前为止运气不好。 我的应用程序也不会再启动了。它总是崩溃 ActivityMain.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/radial_background"
tools:context=".MainActivity"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageButton
android:id="@+id/btnSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dip"
android:src="@drawable/btn_switch_on"
android:background="@null"
android:contentDescription="@null" />
<LinearLayout
android:orientation="vertical"
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"
ads:adUnitId="MY_AD_ID"
ads:adSize="BANNER"/>
</LinearLayout>
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myappname"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</application>
</manifest>
您能告诉我该代码有什么问题吗?您使用的是新版本的admob吗?您必须更改此行: xmlns:ads=http://schemas.android.com/apk/lib/com.google.ads 为此: xmlns:工具=http://schemas.android.com/tools更改此选项
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
到
这对我很有效有人有什么想法吗?好的,我解决了这个问题,但现在我的应用程序无法启动。它崩溃了。我重新启动了电脑,这个问题就解决了。但是我找不到崩溃的答案。发布你的logcat崩溃报告为你的崩溃创建一个新的问题如果你想做任何确认,你应该通过评论来做,并且在你获得50个声誉后,评论是允许的。
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:ads="http://schemas.android.com/apk/res-auto"