我在我的主应用程序中使用 AdMob。但是当我启动一些服务时,我得到了异常:android.view.InflateException: Binary XML file line #134: Error inflating class <unknown>
main
AdMob 布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:orientation="vertical" >
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="xxx"
android:gravity="bottom" />
</LinearLayout>
然后当我运行调用此代码的服务时:
private View getMainLayout() {
LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.main, null);
return layout;
}
我得到例外:
01-26 07:55:56.500: W/dalvikvm(21075): threadid=1: thread exiting with uncaught exception (group=0x40c7a1f8)
01-26 07:55:56.655: E/AndroidRuntime(21075): FATAL EXCEPTION: main
01-26 07:55:56.655: E/AndroidRuntime(21075): java.lang.RuntimeException: Unable to create service com.xxx.sss.service.SmsService: android.view.InflateException: Binary XML file line #134: Error inflating class <unknown>
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2274)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.app.ActivityThread.access$1600(ActivityThread.java:127)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.os.Handler.dispatchMessage(Handler.java:99)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.os.Looper.loop(Looper.java:137)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.app.ActivityThread.main(ActivityThread.java:4511)
01-26 07:55:56.655: E/AndroidRuntime(21075): at java.lang.reflect.Method.invokeNative(Native Method)
01-26 07:55:56.655: E/AndroidRuntime(21075): at java.lang.reflect.Method.invoke(Method.java:511)
01-26 07:55:56.655: E/AndroidRuntime(21075): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
01-26 07:55:56.655: E/AndroidRuntime(21075): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
01-26 07:55:56.655: E/AndroidRuntime(21075): at dalvik.system.NativeStart.main(Native Method)
01-26 07:55:56.655: E/AndroidRuntime(21075): Caused by: android.view.InflateException: Binary XML file line #134: Error inflating class <unknown>
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-26 07:55:56.655: E/AndroidRuntime(21075): at com.xxx.sss.service.SmsService.getMainLayout(SmsService.java:79)
01-26 07:55:56.655: E/AndroidRuntime(21075): at com.xxx.sss.service.SmsService.setOnLabelOnButton(SmsService.java:68)
01-26 07:55:56.655: E/AndroidRuntime(21075): at com.xxx.sss.service.SmsService.onCreate(SmsService.java:37)
01-26 07:55:56.655: E/AndroidRuntime(21075): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2264)
怎么了?