在Android应用程序中找不到类异常

时间:2016-04-14 14:33:20

标签: android

我有类ClipActivity但我不知道为什么我面对这个错误: 我检查了清单路径和类名是否正确。我该怎么办?还有什么可以导致这个问题?

项目的路径:android.app.clip

 04-14 18:39:39.629: I/dalvikvm(29793): Turning on JNI app bug workarounds  for target SDK version 7...
04-14 18:39:39.669: W/dalvikvm(29793): Unable to resolve superclass of Landroid/app/clip/ClipActivity; (462)
04-14 18:39:39.669: W/dalvikvm(29793): Link of class 'Landroid/app/clip/ClipActivity;' failed
04-14 18:39:39.669: D/AndroidRuntime(29793): Shutting down VM
04-14 18:39:39.669: W/dalvikvm(29793): threadid=1: thread exiting with uncaught exception (group=0x41f778b0)
04-14 18:39:39.679: E/AndroidRuntime(29793): FATAL EXCEPTION: main
04-14 18:39:39.679: E/AndroidRuntime(29793): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{android.app.clip/android.app.clip.ClipActivity}: java.lang.ClassNotFoundException: Didn't find class "android.app.clip.ClipActivity" on path: DexPathList[[zip file "/data/app/android.app.clip-2.apk"],nativeLibraryDirectories=[/data/app-lib/android.app.clip-2, /vendor/lib, /system/lib]]
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2192)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.app.ActivityThread.access$600(ActivityThread.java:150)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.os.Looper.loop(Looper.java:213)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.app.ActivityThread.main(ActivityThread.java:5225)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at java.lang.reflect.Method.invokeNative(Native Method)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at java.lang.reflect.Method.invoke(Method.java:525)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at dalvik.system.NativeStart.main(Native Method)
04-14 18:39:39.679: E/AndroidRuntime(29793): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.app.clip.ClipActivity" on path: DexPathList[[zip file "/data/app/android.app.clip-2.apk"],nativeLibraryDirectories=[/data/app-lib/android.app.clip-2, /vendor/lib, /system/lib]]
04-14 18:39:39.679: E/AndroidRuntime(29793):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
04-14 18:39:39.679: E/AndroidRuntime(29793):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2183)
04-14 18:39:39.679: E/AndroidRuntime(29793):    ... 11 more
04-14 18:39:41.511: I/Process(29793): Sending signal. PID: 29793 SIG: 9

清单:

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

    <uses-sdk android:minSdkVersion="7" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".ClipActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

班级代码

    package android.app.clip;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;

public class ClipActivity extends ActionBarActivity {

    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mViewPager = (ViewPager) findViewById(R.id.pager);
/** set the adapter for ViewPager */
        mViewPager.setAdapter(new SamplePagerAdapter(
                getSupportFragmentManager()));
    }

/** Defining a FragmentPagerAdapter class for controlling the fragments to be shown when user swipes on the screen. */
    public class SamplePagerAdapter extends FragmentPagerAdapter {

        public SamplePagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
      /** Show a Fragment based on the position of the current screen */
            if (position == 0) {
                return new SampleFragment();
            } else
                return new SampleFragmentTwo();
        }

        @Override
        public int getCount() {
            // Show 2 total pages.
            return 2;
        }
    }

}

0 个答案:

没有答案