无法实例化活动Componentinfo错误

时间:2014-08-25 04:34:59

标签: java android eclipse actionbarsherlock

我正在尝试使用Sherlock操作栏使我的应用与Android 2.2兼容,但我收到此错误,我无法找到它的解决方案。我已经到处搜索了,他们都说“检查Java构建路径中的Android依赖关系”,但我已经这样做了,错误仍然存​​在。有没有解决方案?

这是我的Logcat:

01-01 01:26:00.879: E/AndroidRuntime(10511): FATAL EXCEPTION: main
01-01 01:26:00.879: E/AndroidRuntime(10511): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.guzi.samphelptools/com.guzi.samphelptools.MainActivity}: java.lang.ClassNotFoundException: com.guzi.samphelptools.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.guzi.samphelptools-1.apk]
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.os.Handler.dispatchMessage(Handler.java:99)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.os.Looper.loop(Looper.java:130)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.app.ActivityThread.main(ActivityThread.java:3687)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at java.lang.reflect.Method.invokeNative(Native Method)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at java.lang.reflect.Method.invoke(Method.java:507)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at dalvik.system.NativeStart.main(Native Method)
    01-01 01:26:00.879: E/AndroidRuntime(10511): Caused by: java.lang.ClassNotFoundException: com.guzi.samphelptools.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.guzi.samphelptools-1.apk]
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
    01-01 01:26:00.879: E/AndroidRuntime(10511):    ... 11 more

这是我在清单中的一些内容:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Sherlock" >
    <activity
        android:name="com.guzi.samphelptools.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

MainActivity的一部分:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTheme(R.style.Theme_Sherlock);

    AdView ad = (AdView)findViewById(R.id.adView);
    ad.loadAd(new AdRequest());

0 个答案:

没有答案