Android 每次我运行应用程序时,它都会崩溃
activity_main.xmlAndroid 每次我运行应用程序时,它都会崩溃,android,admob,Android,Admob,activity_main.xml <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:layout_height="fill_parent"&g
<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:layout_height="fill_parent">
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="@string/hello_world"/>
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="***************"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR" /> </RelativeLayout>
我想显示广告,但我的应用程序每次运行都会崩溃。我在4.2.2API 17级模拟器上运行它。我错在哪里
对类com.admob.android.ads.AdView进行充气时出错
出现此错误是因为AdView类不在com.admob.android.ads
包中,而是在com.google.ads
包中
因此,改变这一点:
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="***************"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR" />
为此:
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="***************"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR" />
日志中的崩溃说明了什么?控制台中显示:[2013-04-01 12:10:54-Emulator]无法获取WglGetExtensionsStringarb这不是我的意思。如果你崩溃了,一个完整的堆栈跟踪你崩溃的地方应该在那里。这就是我们需要的。你的问题应该显示出适当的研究和努力,然后马上发布。在这里发布之前,请了解eclipse和android的基本情况。LocGate:04-01 06:44:07.329:E/AndroidRuntime(644):致命异常:main 04-01 06:44:07.329:E/AndroidRuntime(644):java.lang.RuntimeException:无法启动活动组件信息{com.example.simplebanerad/com.example.simplebanerad.MainActivity}:android.view.InflateException:二进制XML文件行#12:错误膨胀类com.admob.android.ads.AdView 04-01 06:44:07.329:E/AndroidRuntime(644):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)04-01 06:44:07.329:E/AndroidRuntime(644):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)编辑您的问题并添加日志。04-01 07:46:04.996:E/AndroidRuntime(1980):致命异常:main 04-01 07:46:04.996:E/AndroidRuntime(1980):java.lang.RuntimeException:无法启动活动组件信息{com.example.simplebanerad/com.example.simplebanerad.MainActivity}:android.view.InflateException:二进制XML文件行#12:膨胀类com.google.ads.AdView时出错
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="***************"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR" />
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="***************"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR" />