Android的无法启动活动,错误充气类? [英] Android unable to start activity, error inflating class?

查看:200
本文介绍了Android的无法启动活动,错误充气类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的机器人。我有一些Java知识,我使用的Eclipse。 目前,我试图显示选项卡中的地图,并在看教程/ code来帮助我。 :)

我已经看到了一些问题,问到这个错误,但我想不出什么我做错了,还是。 我使用的是从这里code:<一href="http://vkroz.word$p$pss.com/2009/07/03/programming-android-%E2%80%93-map-view-within-tab-view/" rel="nofollow">http://vkroz.word$p$pss.com/2009/07/03/programming-android-%E2%80%93-map-view-within-tab-view/

我是不是失去了一些东西明显?

在运行时异常e值:

 了java.lang.RuntimeException:无法启动活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:... android.view.InflateException:二进制XML文件行#24:错误充气类&lt;未知&GT;
 

第24行仅仅是&LT; / LinearLayout中&GT;

全main.xml中的:

 &LT; XML版本=1.0编码=UTF-8&GT?;

&LT; TabHost的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@机器人:ID / tabhost
    机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT&GT;

    &LT;的LinearLayout机器人:方向=垂直
        机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT&GT;

        &LT; TabWidget机器人:ID =@机器人:ID /标签
            机器人:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT/&GT;

        &LT;的FrameLayout机器人:ID =@机器人:ID / tabcontent
                机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT&GT;

                &LT; RelativeLayout的机器人:ID =@ + ID / emptylayout1机器人:方向=垂直
                    机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT/&GT;

                &LT; TextView的机器人:ID =@ + ID / textview2
                    机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT
                    机器人:文本=详细详细详细详细/&GT;

        &LT; /的FrameLayout&GT;
    &LT; / LinearLayout中&GT;
&LT; / TabHost&GT;
 

我的code,其余是一样的联系,但我将它贴在这里了。

MapInTabActivity.java

 包com.test.mapintab;

进口android.app.TabActivity;
进口android.content.Context;
进口android.content.Intent;
进口android.os.Bundle;
进口android.widget.FrameLayout;
进口android.widget.TabHost;
进口android.widget.TabHost.TabSpec;

公共类MapInTabActivity扩展TabActivity {

    TabHost mTab​​Host;
    的FrameLayout mFrameLayout;

    / **第一次创建活动时调用。 * /
    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);

        mTabHost = getTabHost();
        则tabspec则tabspec = mTab​​Host.newTabSpec(tab_test1);
        tabSpec.setIndicator(地图);
        上下文CTX = this.getApplicationContext();
        意图I =新的意图(CTX,MapInTabActivity.class);
        tabSpec.setContent(ⅰ);

        mTabHost.addTab(则tabspec);
        mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Details").setContent(R.id.textview2));
        mTabHost.setCurrentTab(0);

    }

}
 

MapTabView.java:

 包com.test.mapintab;

进口android.os.Bundle;

进口com.google.android.maps.MapActivity;

公共类MapTabView扩展MapActivity {

    @覆盖
    保护无效的onCreate(包冰柱){
        super.onCreate(冰柱);
        的setContentView(R.layout.maptabview);
    }

    @覆盖
    保护的布尔isRouteDisplayed(){
        返回false;
    }

}
 

maptabview.xml:

 &LT; XML版本=1.0编码=UTF-8&GT?;

&LT; RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / maptablayout
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT&GT;

    &LT; com.google.android.maps.MapView机器人:ID =@ + ID /图形页面
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:可点击=真
        机器人:apiKey =0HRMcD5o6WrBVhmwbWpeyeavZ67PXWOvJeeCx2g/&GT;

&LT; / RelativeLayout的&GT;
 

清单:

 &LT; XML版本=1.0编码=UTF-8&GT?;
&LT;舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.test.mapintab
    安卓版code =1
    机器人:VERSIONNAME =1.0&GT;

    &LT;使用-SDK安卓的minSdkVersion =8/&GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.INTERNET对&GT;&LT; /使用-许可&GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.ACCESS_COARSE_LOCATION&GT;&LT; /使用-许可&GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION&GT;&LT; /使用-许可&GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.ACCESS_LOCATION_EXTRA_COMMANDS&GT;&LT; /使用-许可&GT;

    &lt;应用
        机器人:图标=@可绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME&GT;
        &LT;使用库机器人:名称=com.google.android.maps/&GT;

        &LT;活动
            MapInTabActivity:机器人名=机器人:标签=@字符串/ APP_NAME&GT;
            &LT;意向滤光器&gt;
                &lt;作用机器人:名称=android.intent.action.MAIN/&GT;
                &LT;类机器人:名称=android.intent.category.LAUNCHER/&GT;
            &所述; /意图滤光器&gt;
        &LT; /活性GT;

       &LT;活动机器人:MapTabView名称=机器人:标签=@字符串/ mapview_name&GT;
           &LT;意向滤光器&gt;
              &LT;类机器人:名称=android.intent.category.EMBED&GT;&LT; /类&GT;
              &lt;作用机器人:名称=android.intent.action.MAIN&GT;&LT; /作用&gt;
           &所述; /意图滤光器&gt;
        &LT; /活性GT;

    &LT; /用途&gt;
&LT; /舱单&GT;
 

和logcat中的其余部分(我认为重要的部分是,我指出了在顶部位,但也许还有别的我不知道)。

  9月2日至五日:49:21.239:W / dalvikvm(357):主题ID = 1:螺纹退出与未捕获的异常(组= 0x4001d800)
9月2日至5号:49:22.616:E / AndroidRuntime(357):致命异常:主要
9月2日至5号:49:22.616:E / AndroidRuntime(357):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang中.RuntimeException:无法启动活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity} :java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test。 mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {融为一体。 test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:JAVA。 lang.RuntimeException:无法启动活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:android.view.InflateException:二进制XML文件中的行#24:错误充气类&lt;未知&GT;
9月2日至5号:49:22.616:E / AndroidRuntime(357):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在android.app.ActivityThread.access $ 2300(ActivityThread.java:125)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:2033)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在android.os.Handler.dispatchMessage(Handler.java:99)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在android.os.Looper.loop(Looper.java:123)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在android.app.ActivityThread.main(ActivityThread.java:4627)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在java.lang.reflect.Method.invokeNative(本机方法)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在java.lang.reflect.Method.invoke(Method.java:521)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
9月2日至5号:49:22.616:E / AndroidRuntime(357):在dalvik.system.NativeStart.main(本机方法)
9月2日至5号:49:22.616:E / AndroidRuntime(357):java.lang.RuntimeException的:产生的原因无法启动活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang中。 RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab .MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / COM .test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test.mapintab / com.test.mapintab.MapInTabActivity}:java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.test .mapintab / com.test.mapintab.MapInTabActivit
 

解决方案

我想,你是以下链接的例子。它工作正常在我结束。你的清单文件说,你还没有宣布在清单文件中的MapTabView活动。在你的清单中使用此

 &LT;活动机器人:MapTabView名称=机器人:标签=@字符串/ mapview_name&GT;
   &LT;意向滤光器&gt;
      &LT;类机器人:名称=android.intent.category.EMBED&GT;&LT; /类&GT;
      &lt;作用机器人:名称=android.intent.action.MAIN&GT;&LT; /作用&gt;
   &所述; /意图滤光器&gt;
&LT; /活性GT;
 

希望这有助于!

I'm new to android. I have some java knowledge, and I'm using Eclipse. At the moment I'm trying to display a map within a tab, and am looking at tutorials/code to help me. :)

I've seen a few questions asking about this error, but I can't figure out what I'm doing wrong, still. I'm using code from here: http://vkroz.wordpress.com/2009/07/03/programming-android-%E2%80%93-map-view-within-tab-view/

Am I just missing something obvious?

The value of the runtime exception e:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: ... android.view.InflateException: Binary XML file line #24: Error inflating class <unknown>

Line 24 is just </LinearLayout>

The whole of main.xml:

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent" android:layout_height="fill_parent">

    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" android:layout_height="fill_parent">

        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent" android:layout_height="wrap_content"/>

        <FrameLayout android:id="@android:id/tabcontent"
                android:layout_width="fill_parent" android:layout_height="fill_parent">

                <RelativeLayout android:id="@+id/emptylayout1" android:orientation="vertical"
                    android:layout_width="fill_parent" android:layout_height="fill_parent"/>

                <TextView android:id="@+id/textview2"
                    android:layout_width="fill_parent" android:layout_height="fill_parent"
                    android:text="Details Details Details Details"/>

        </FrameLayout>
    </LinearLayout> 
</TabHost>

The rest of my code is the same as linked, but I'll paste it here too.

MapInTabActivity.java

package com.test.mapintab;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class MapInTabActivity extends TabActivity {

    TabHost mTabHost;
    FrameLayout mFrameLayout;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mTabHost = getTabHost();
        TabSpec tabSpec = mTabHost.newTabSpec("tab_test1");
        tabSpec.setIndicator("Map");
        Context ctx = this.getApplicationContext();
        Intent i = new Intent(ctx, MapInTabActivity.class);
        tabSpec.setContent(i);

        mTabHost.addTab(tabSpec);
        mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Details").setContent(R.id.textview2));
        mTabHost.setCurrentTab(0);

    }

}

MapTabView.java:

package com.test.mapintab;

import android.os.Bundle;

import com.google.android.maps.MapActivity;

public class MapTabView extends MapActivity{

    @Override
    protected void onCreate(Bundle icicle){
        super.onCreate(icicle);
        setContentView(R.layout.maptabview);
    }

    @Override
    protected boolean isRouteDisplayed(){
        return false;
    }

}

maptabview.xml:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/maptablayout"
    android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent">

    <com.google.android.maps.MapView android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"            
        android:apiKey="0HRMcD5o6WrBVhmwbWpeyeavZ67PXWOvJeeCx2g"/>

</RelativeLayout>

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.mapintab"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <uses-library android:name="com.google.android.maps"/>

        <activity
            android:name=".MapInTabActivity" 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=".MapTabView" android:label="@string/mapview_name">
           <intent-filter>
              <category android:name="android.intent.category.EMBED"></category>
              <action android:name="android.intent.action.MAIN"></action>
           </intent-filter>
        </activity>

    </application>
</manifest>

And the rest of logcat (I think the important part was the bit I pointed out at the top, but maybe there's something else I don't know about).

02-05 09:49:21.239: W/dalvikvm(357): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-05 09:49:22.616: E/AndroidRuntime(357): FATAL EXCEPTION: main
02-05 09:49:22.616: E/AndroidRuntime(357): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class <unknown>
02-05 09:49:22.616: E/AndroidRuntime(357):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-05 09:49:22.616: E/AndroidRuntime(357):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-05 09:49:22.616: E/AndroidRuntime(357):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-05 09:49:22.616: E/AndroidRuntime(357):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-05 09:49:22.616: E/AndroidRuntime(357):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-05 09:49:22.616: E/AndroidRuntime(357):  at android.os.Looper.loop(Looper.java:123)
02-05 09:49:22.616: E/AndroidRuntime(357):  at android.app.ActivityThread.main(ActivityThread.java:4627)
02-05 09:49:22.616: E/AndroidRuntime(357):  at java.lang.reflect.Method.invokeNative(Native Method)
02-05 09:49:22.616: E/AndroidRuntime(357):  at java.lang.reflect.Method.invoke(Method.java:521)
02-05 09:49:22.616: E/AndroidRuntime(357):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-05 09:49:22.616: E/AndroidRuntime(357):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-05 09:49:22.616: E/AndroidRuntime(357):  at dalvik.system.NativeStart.main(Native Method)
02-05 09:49:22.616: E/AndroidRuntime(357): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.mapintab/com.test.mapintab.MapInTabActivit

解决方案

I tried the example that link you are following. Its working fine in my end. Your Manifest file says, you have not declared the MapTabView activity in the Manifest file. Use this in your manifest

<activity android:name=".MapTabView" android:label="@string/mapview_name">
   <intent-filter>
      <category android:name="android.intent.category.EMBED"></category>
      <action android:name="android.intent.action.MAIN"></action>
   </intent-filter>
</activity>

Hope this helps !

这篇关于Android的无法启动活动,错误充气类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆