2014-02-18 84 views
0

我試圖開發使用儀表盤的設計方法,其主頁的應用程序。但我得到一個運行時錯誤。這裏是logcat的:拋出java.lang.ClassNotFoundException:找不到類「com.example.cinema.DashboardLayout」

02-18 13:43:21.488: D/dalvikvm(1248): Late-enabling CheckJNI 
02-18 13:43:21.612: D/dalvikvm(1248): GC_CONCURRENT freed 103K, 21% free 2753K/3456K, paused 5ms+1ms, total 10ms 
02-18 13:43:21.616: D/dalvikvm(1248): GC_FOR_ALLOC freed 11K, 20% free 2943K/3656K, paused 2ms, total 2ms 
02-18 13:43:21.628: I/dalvikvm-heap(1248): Grow heap (frag case) to 4.221MB for 805500-byte allocation 
02-18 13:43:21.628: D/dalvikvm(1248): GC_FOR_ALLOC freed 1K, 17% free 3728K/4444K, paused 3ms, total 3ms 
02-18 13:43:21.632: D/dalvikvm(1248): GC_CONCURRENT freed 0K, 17% free 3728K/4444K, paused 1ms+0ms, total 2ms 
02-18 13:43:21.640: D/AndroidRuntime(1248): Shutting down VM 
02-18 13:43:21.644: W/dalvikvm(1248): threadid=1: thread exiting with uncaught exception (group=0xa4c45648) 
02-18 13:43:21.644: E/AndroidRuntime(1248): FATAL EXCEPTION: main 
02-18 13:43:21.644: E/AndroidRuntime(1248): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.cinema/org.example.cinema.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class com.example.cinema.DashboardLayout 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.ActivityThread.access$600(ActivityThread.java:141) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.os.Handler.dispatchMessage(Handler.java:99) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.os.Looper.loop(Looper.java:137) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.ActivityThread.main(ActivityThread.java:5103) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at java.lang.reflect.Method.invoke(Method.java:525) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at dalvik.system.NativeStart.main(Native Method) 
02-18 13:43:21.644: E/AndroidRuntime(1248): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class com.example.cinema.DashboardLayout 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:816) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.Activity.setContentView(Activity.java:1895) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at org.example.cinema.MainActivity.onCreate(MainActivity.java:14) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.Activity.performCreate(Activity.java:5133) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  ... 11 more 
02-18 13:43:21.644: E/AndroidRuntime(1248): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.cinema.DashboardLayout" on path: DexPathList[[zip file "/data/app/org.example.cinema-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.example.cinema-2, /system/lib]] 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.view.LayoutInflater.createView(LayoutInflater.java:559) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
02-18 13:43:21.644: E/AndroidRuntime(1248):  ... j22 more 

我有DashboarLayout.java和代碼如下部分:

package org.example.cinema; 

import android.content.Context; 
import android.util.AttributeSet; 
import android.view.View; 
import android.view.ViewGroup; 


public class DashboardLayout extends ViewGroup { 

    private static final int UNEVEN_GRID_PENALTY_MULTIPLIER = 10; 

    private int mMaxChildWidth = 0; 
    private int mMaxChildHeight = 0; 

    public DashboardLayout(Context context) { 
     super(context, null); 
    } 

    public DashboardLayout(Context context, AttributeSet attrs) { 
     super(context, attrs, 0); 
    } 

    public DashboardLayout(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
    } 
     ............ 

和使用這個類的XML佈局文件的樣子:

<com.example.cinema.DashboardLayout> 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    ........ 
</com.example.cinema.DashboardLayout> 

和我的MainActivity.java:

package org.example.cinema; 
import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import org.example.cinema.R; 

public class MainActivity extends Activity { 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.dashboard_layout); 

    .......... 
+0

你有一個名爲'com.example.cinema.DashboardLayout'類? –

+0

發佈您的相關代碼。 –

+1

檢查您的佈局'造成的:android.view.InflateException:二進制XML文件行#1:錯誤充氣類com.example.cinema.DashboardLayout' –

回答

6

佈局指的是com.example.cinema.DashboardLayout。你有的班是org.example.cinema.DashboardLayout。這些需要是一樣的。最簡單的解決方案是在佈局中將com替換爲org

相關問題