dalvikvm:找不到类

Posted

技术标签:

【中文标题】dalvikvm:找不到类【英文标题】:dalvikvm: Could not find class 【发布时间】:2016-08-30 21:13:12 【问题描述】:

使用 API 17-20 运行 avd 时出现以下错误并崩溃。 API 23 没有出现此错误。我使用的是 android Studio 2.0。

05-06 02:31:48.252 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.252 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.252 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.252 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.252 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.256 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.256 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.256 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.260 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.260 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.260 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.xxx.android.Splash.access$super
05-06 02:31:48.260 1544-1544/com.xxx.android E/dalvikvm: Could not find class 'com.xxx.android.HomeScreen', referenced from method com.xxx.android.Splash.onCreate
05-06 02:31:48.772 1544-1544/com.xxx.android E/AndroidRuntime: FATAL EXCEPTION: main
                                                               Process: com.xxx.android, PID: 1544
                                                               java.lang.NoClassDefFoundError: com.xxx.android.HomeScreen
                                                                   at com.xxx.android.Splash.onCreate(Splash.java:28)
                                                                   at android.app.Activity.performCreate(Activity.java:5231)
                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:136)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:5001)
                                                                   at java.lang.reflect.Method.invokeNative(Native Method)
                                                                   at java.lang.reflect.Method.invoke(Method.java:515)
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                   at dalvik.system.NativeStart.main(Native Method)

这是有问题的代码:

公共类 Splash 扩展 AppCompatActivity @覆盖 protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); Intent intent = new Intent(this, com.xxx.android.HomeScreen.class); 开始活动(意图); 结束();

AndroidManifest.xml:

<application
    android:name="xxxApp"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/StartupTheme">

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name="com.xxx.android.Splash"
        android:theme="@style/StartupTheme">

        <meta-data
            android:name="android.app.searchable"
            android:resource="@xml/searchable"/>
        <intent-filter>
            <action android:name="android.intent.action.SEARCH"/>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.xxx.android.HomeScreen"
        android:label="@string/app_name"
        android:theme="@style/xxxTheme">
        <!--android:theme="@style/Theme.AppCompat.NoActionBar">-->
    </activity>

有什么想法吗?

【问题讨论】:

清理并构建项目,然后尝试再次运行。 清理和构建没有区别。 您是否在 AndroidManifest 中声明了 HomeScreen Activity? 是的,刚刚编辑显示AndroidManifest.xml 问题解决了吗? 【参考方案1】:

这是您使用的模拟器出错。 AVD 未正确安装,堆栈跟踪显示设备的启动器正在引发异常。

【讨论】:

以上是关于dalvikvm:找不到类的主要内容,如果未能解决你的问题,请参考以下文章

控制器类找不到 html 模板

php thinkphp vender第三方类找不到类怎么解决

Eclipse中HttpServlet类找不到

RegistryKey与RegistryValue类找不到问题处理

RegistryKey与RegistryValue类找不到问题处理

RegistryKey与RegistryValue类找不到问题处理