无法启动活动android.view.InflateException

时间:2012-03-09 03:12:32

标签: android android-intent android-manifest

我有一个创建的android项目,在其中我创建了两个包

  --net.website.custom_listview
       --main_activity_customview.java
       --other files .....
  --net.website.dashboard
       --main_activity_dashboard.java
       --other files .....

在我的AndroidManifest.xml文件中

<activity            
    android:name="net.website.dashboard.main_activity_dashboard"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

所以当我运行Android应用程序时,我收到以下错误..

这是我的logCat:

03-08 22:02:03.941: E/AndroidRuntime(691): FATAL EXCEPTION: main
03-08 22:02:03.941: E/AndroidRuntime(691): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.website/net.website.dashboard.Main_Activity_Dashboard}: android.view.InflateException: Binary XML file line #1: Error inflating class net.website.dashboard
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.os.Looper.loop(Looper.java:123)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.app.ActivityThread.main(ActivityThread.java:3683)
03-08 22:02:03.941: E/AndroidRuntime(691):  at java.lang.reflect.Method.invokeNative(Native Method)
03-08 22:02:03.941: E/AndroidRuntime(691):  at java.lang.reflect.Method.invoke(Method.java:507)
03-08 22:02:03.941: E/AndroidRuntime(691):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-08 22:02:03.941: E/AndroidRuntime(691):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-08 22:02:03.941: E/AndroidRuntime(691):  at dalvik.system.NativeStart.main(Native Method)
03-08 22:02:03.941: E/AndroidRuntime(691): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class net.website.dashboard
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:684)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-08 22:02:03.941: E/AndroidRuntime(691):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.app.Activity.setContentView(Activity.java:1657)
03-08 22:02:03.941: E/AndroidRuntime(691):  at net.website.dashboard.Main_Activity_Dashboard.onCreate(Main_Activity_Dashboard.java:16)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-08 22:02:03.941: E/AndroidRuntime(691):  ... 11 more
03-08 22:02:03.941: E/AndroidRuntime(691): Caused by: java.lang.ClassNotFoundException: net.website.dashboard in loader dalvik.system.PathClassLoader[/data/app/net.website-2.apk]
03-08 22:02:03.941: E/AndroidRuntime(691):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-08 22:02:03.941: E/AndroidRuntime(691):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-08 22:02:03.941: E/AndroidRuntime(691):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.view.LayoutInflater.createView(LayoutInflater.java:471)
03-08 22:02:03.941: E/AndroidRuntime(691):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)

2 个答案:

答案 0 :(得分:3)

问题出在布局XML文件中。您正在引用“net.website.dashboard”类,但它不存在。

答案 1 :(得分:0)

您必须更改包的名称,然后必须检查此内容。还要检查您的xml文件