4

我正在使用 ActionBarSherlock 和 SlidingMenu 库以及 IDE IntelliJ IDEA 启动一个 Android 应用程序。我在包含 2 个库时遇到了很多问题,但最后,尝试了许多不同的项目结构,项目编译没有错误。

但是现在,当我启动我的应用程序时,我有一个 ClassNotFoundException :

03-06 20:21:17.046: ERROR/AndroidRuntime(301): FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.istic.tonightsbar/org.istic.tonightsbar.StartActivity}: java.lang.ClassNotFoundException: org.istic.tonightsbar.StartActivity in loader dalvik.system.PathClassLoader[/data/app/org.istic.tonightsbar-1.apk]
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.ClassNotFoundException: org.istic.tonightsbar.StartActivity in loader dalvik.system.PathClassLoader[/data/app/org.istic.tonightsbar-1.apk]
    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
    ... 11 more

我阅读了很多关于这个错误的主题,但我没有找到 IntelliJ 的任何解决方案。我能解决这个问题吗?

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.istic.tonightsbar"
      android:versionCode="1"
      android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>
<application android:label="@string/app_name">
    <activity android:name=".StartActivity"
              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>

和 StartActivity.java :

package org.istic.tonightsbar;

import android.os.Bundle;
import com.actionbarsherlock.app.ActionBar;
import com.slidingmenu.lib.SlidingMenu;
import com.slidingmenu.lib.app.SlidingFragmentActivity;

public class StartActivity extends SlidingFragmentActivity {
/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_Sherlock);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ActionBar ab = getSupportActionBar();
    ab.setIcon(android.R.drawable.btn_plus);
//ab.setBackgroundDrawable(getResources().getDrawable(R.drawable.background_actionbar));

    // customize the SlidingMenu
    SlidingMenu menu = getSlidingMenu();
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
//        menu.setShadowDrawable(R.drawable.shadow);
//        menu.setBehindOffsetRes(R.dimen.actionbar_home_width);
    menu.setFadeEnabled(true);
    menu.setFadeDegree(0.95f);

    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);

}
}

感谢您未来的回答,

艾努尔56

4

0 回答 0