7

我有一个使用WelcomeActivitywhich extends的项目FragmentActivity。我使用支持库,文件夹android-support-v4.jar中也是如此。libs当我运行这个应用程序时,没有任何问题。

但是,我想将 ActionBarSherlock 添加到项目中。在我使用的ABS 项目actionbarsherlock-plugin-maps-4.1.0.jar和文件夹中。在我的应用程序项目中,我添加了 ABS 库,当我尝试运行该应用程序时,出现此错误:android-support-v4-r6-googlemaps.jarlibs

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;

为了解决这个问题,我android-support-v4.jar从我的应用程序libs文件夹中删除了 。当我现在启动我的应用程序时,应用程序会因以下 logcat 而崩溃:

08-01 18:59:11.182: W/dalvikvm(13338): Unable to resolve superclass of Landroid/support/v4/app/FragmentActivity; (620)
08-01 18:59:11.182: W/dalvikvm(13338): Link of class 'Landroid/support/v4/app/FragmentActivity;' failed
08-01 18:59:11.182: W/dalvikvm(13338): Unable to resolve superclass of Lcom/myapp/welcome/WelcomeActivity; (109)
08-01 18:59:11.182: W/dalvikvm(13338): Link of class 'Lcom/myapp/welcome/WelcomeActivity;' failed
08-01 18:59:11.182: E/dalvikvm(13338): Could not find class 'com.myapp.welcome.WelcomeActivity', referenced from method com.myapp.MainDispatcherActivity.startWelcomeActivity
08-01 18:59:11.182: W/dalvikvm(13338): VFY: unable to resolve const-class 690 (Lcom/myapp/welcome/WelcomeActivity;) in Lcom/myapp/MainDispatcherActivity;
08-01 18:59:11.182: D/dalvikvm(13338): VFY: replacing opcode 0x1c at 0x0002
08-01 18:59:11.182: D/dalvikvm(13338): VFY: dead code 0x0004-000b in Lcom/myapp/MainDispatcherActivity;.startWelcomeActivity ()V
08-01 18:59:11.182: D/AndroidRuntime(13338): Shutting down VM
08-01 18:59:11.182: W/dalvikvm(13338): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-01 18:59:11.182: E/AndroidRuntime(13338): FATAL EXCEPTION: main
08-01 18:59:11.182: E/AndroidRuntime(13338): java.lang.NoClassDefFoundError: com.myapp.welcome.WelcomeActivity
08-01 18:59:11.182: E/AndroidRuntime(13338):    at com.myapp.MainDispatcherActivity.startWelcomeActivity(MainDispatcherActivity.java:33)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at com.myapp.MainDispatcherActivity.startProperActivity(MainDispatcherActivity.java:26)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at com.myapp.MainDispatcherActivity.onCreate(MainDispatcherActivity.java:19)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at android.os.Looper.loop(Looper.java:130)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at android.app.ActivityThread.main(ActivityThread.java:3683)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at java.lang.reflect.Method.invokeNative(Native Method)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at java.lang.reflect.Method.invoke(Method.java:507)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
08-01 18:59:11.182: E/AndroidRuntime(13338):    at dalvik.system.NativeStart.main(Native Method)

我怎样才能解决这个问题?

编辑
我有另一个使用相同 ABS 库的项目,并且运行良好。我不知道我做了什么不同,或者哪些设置是错误的。

4

4 回答 4

13

<application>似乎发生此错误是因为我在标记中的 AndroidManifest.xml 文件中没有这一行:

<uses-library android:name="com.google.android.maps" />
于 2012-08-01T19:32:55.080 回答
9

点击这里

我认为在构建路径-> 配置构建路径-> 订购和导出处是同样的问题,需要检查“android-support-v4.jar”。

希望对你有用。

于 2013-06-14T08:25:32.170 回答
2

您是否为 actionbarsherlock 库项目设置了编译器合规性?右键单击库项目,转到属性。在 java 编译器下,确保合规性设置为 1.6。我遇到了类似的问题,发现合规性设置为 1.5。

于 2012-08-01T17:44:27.947 回答
0

我自己没有遇到过,但我认为文档说你需要ActionBarSherlock扩展SherlockFragmentActivity而不是FragmentActivity. 这可能不是问题,但它是一个问题

于 2012-08-01T17:21:12.647 回答