当同时使用ActionBarSherlock和ViewPagerIndicator时,出现以下错误;根据我的阅读-这是由于两者中的库冲突/重复造成的。

一种解决方案是让ABS依赖VPI(或者反过来说,我都尝试了这两种方法),但是即使进行了清理和重建,这仍然给我同样的错误。现在,我只是在两个单独的项目中工作,所以我可以完成工作-但我想将它们显然结合起来。帮助将不胜感激!

[2012-04-19 00:39:20 - MashableReader] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.dx.command.dexer.Main.run(Main.java:206)
[2012-04-19 00:39:20 - MashableReader] Dx   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2012-04-19 00:39:20 - MashableReader] Dx   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[2012-04-19 00:39:20 - MashableReader] Dx   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[2012-04-19 00:39:20 - MashableReader] Dx   at java.lang.reflect.Method.invoke(Unknown Source)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:180)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:702)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:646)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.resources.Project.build(Project.java:124)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1000)
[2012-04-19 00:39:20 - MashableReader] Dx   at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:147)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:928)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1132)
[2012-04-19 00:39:20 - MashableReader] Dx   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[2012-04-19 00:39:20 - MashableReader] Dx 1 error; aborting
[2012-04-19 00:39:20 - MashableReader] Conversion to Dalvik format failed with error 1

用答案更新:
好的-正如下面的答案所示,问题是Eclipse ADT中的依赖关系解析。基本上,我的解决方案是使ViewPagerIndicator依赖ActionBarSherlock(这意味着,在VPI属性中,我像在常规项目中一样向项目中添加ABS-对于那些可能向后思考的人)。当我在代码中遇到错误时说仍然无法解决某些方法时,我仍然遇到问题-这部分是因为您的导入错误,因此请删除所有导入和CRTL + SHIFT + O(快速导入解析) ),然后从android.support.v4包中选择所有的包,那么您应该会做得很好。但是后来我仍然遇到了原始的Dalvik问题-要解决此问题,我必须进入我的VPI库所在的实际文件夹,并从/libs文件夹中删除支持jar以阻止其获取它-然后全部完成:)

最佳答案

是的,问题出在ActionBarSherlock和ViewPagerIndicator都使用libs/android-support-v4.jar依赖关系。
最简单的解决方案是将您的工作站升级到最新的Android SDK和Eclipse ADT插件版本(至少为r17),因为这种情况现在已由SDK自动处理(从r17开始),请参见r17 changelog:

还要注意,由于r17,libs文件夹下的所有jar文件都将自动填充到项目的类路径中,因此您不再需要手动将它们添加到项目的构建路径中,这也在r17 changelog中提到:

希望这可以帮助。

关于android - 同步使用ActionBarSherlock和ViewPagerIndicator将无法编译,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10236242/

10-12 00:24