简体   繁体   English

java.lang.ClassNotFoundException:找不到类“ com.example.cinema.DashboardLayout”

[英]java.lang.ClassNotFoundException: Didn't find class “com.example.cinema.DashboardLayout”

I am trying to develop an app that uses dashboard design method as its home page. 我正在尝试开发一个使用仪表板设计方法作为其主页的应用程序。 but I'm getting a run time error. 但出现运行时错误。 Here is the logcat: 这是logcat:

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

I have DashboarLayout.java and the code looks like this partially: 我有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);
    }
         ............

and the xml layout file which uses this class looks like: 使用此类的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>

and my MainActivity.java: 和我的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);

  ..........

The layout refers to com.example.cinema.DashboardLayout . 布局引用com.example.cinema.DashboardLayout The class you have is org.example.cinema.DashboardLayout . 您拥有的类是org.example.cinema.DashboardLayout These need to be the same. 这些必须相同。 The simplest solution is to replace com with org in the layout. 最简单的解决方案是在布局中用org替换com

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.ClassNotFoundException:在路径上没有找到类“com.example.justjava.MainActivity” - java.lang.ClassNotFoundException: Didn't find class "com.example.justjava.MainActivity" on path 无法解析java.lang.ClassNotFoundException:在Android Studio中找不到类“ com.example.android.camera2basic.AutoFitTextureView”吗? - Unable to resolve java.lang.ClassNotFoundException: Didn't find class “com.example.android.camera2basic.AutoFitTextureView” in android studio? 由java.lang.ClassNotFoundException引起找不到类“ com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver - Caused by java.lang.ClassNotFoundException Didn't find class "com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver java.lang.ClassNotFoundException:找不到类“ com.life.Life” - java.lang.ClassNotFoundException: Didn't find a class “com.life.Life” java.lang.ClassNotFoundException:找不到类“ com.google.android.maps.MapView” - java.lang.ClassNotFoundException: Didn't find class “com.google.android.maps.MapView” React Native java.lang.ClassNotFoundException:找不到类 - React Native java.lang.ClassNotFoundException: Didn't find class java.lang.ClassNotFoundException:找不到类“ com.androidhive.jsonparsing.Search_medicine” - java.lang.ClassNotFoundException: Didn't find class “com.androidhive.jsonparsing.Search_medicine” java.lang.ClassNotFoundException:未找到类“com.google.android.gms.ads.MobileAdsInitProvider” - java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" java.lang.ClassNotFoundException:在路径上找不到 class“com.sun.mail.util.MailLogger”: - java.lang.ClassNotFoundException: Didn't find class "com.sun.mail.util.MailLogger" on path: 原因:java.lang.ClassNotFoundException:在路径上找不到类 - Caused by: java.lang.ClassNotFoundException: Didn't find class on path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM