使用 ActionBarSherlock &ViewPagerIndicator 同步不会编译 [英] Using ActionBarSherlock & ViewPagerIndicator Synchronously Will Not Compile

查看:21
本文介绍了使用 ActionBarSherlock &ViewPagerIndicator 同步不会编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When using ActionBarSherlock and ViewPagerIndicator at the same time I am getting the below error; from what I've read - it's caused due to conflicting/duplicate libraries in the two.

一个解决方案是让 ABS 依赖于 VPI(或者相反,我都尝试了)但是即使在清理和重建之后,这仍然给了我同样的错误.现在我只是在两个独立的项目中工作,所以我可以完成我的工作——但我显然想把它们结合起来哈.非常感谢您的帮助!

One solution was to have ABS rely on VPI (Or the other way around, I tried both) but this still gave me the same error even after a clean and rebuild. Right now I'm just working in two separate projects so I can get my work done - but I'd like to combine them obviously ha. Help would be much appreciated!

[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 以阻止它抓取它 - 然后全部设置 :)

UPDATE WITH ANSWER: Alright - as the answer below gets at, the issue was the dependency resolution in the Eclipse ADT. Basically my solution was to make the ViewPagerIndicator rely on ActionBarSherlock (Meaning, in the VPI properties, I add ABS to the project like you would for a regular project - for those of you who might be thinking backwards). I still had issues with that when I was getting errors in my code saying some of the methods couldn't be overridden - this part is because you have the wrong imports, so delete all your imports and CRTL+SHIFT+O (Quick import resolution) and select all the ones from the android.support.v4 packages and you should be all good on that. But then I still ran into the original Dalvik issue - to fix this I had to go into the actual folder where my VPI library was and delete the support jar from the /libs folder to stop it from grabbing it - then all set :)

推荐答案

是的,问题是 ActionBarSherlock 和 ViewPagerIndicator 都使用 libs/android-support-v4.jar 依赖.

Yes, the problem is both ActionBarSherlock and ViewPagerIndicator use libs/android-support-v4.jar dependency.

最简单的解决方案是将您的工作站升级到最新的 Android SDK 和 Eclipse ADT 插件版本(至少 r17),因为这种情况现在由 SDK 自动处理(自 r17 起),请参阅 r17 changelog:

The simplest solution is upgrade your work station to latest Android SDK and Eclipse ADT plugin version (at least r17), as this situation is automatically handled by the SDK now (since r17), see the r17 changelog:

当一个项目引用了两个需要相同 jar 文件的库项目时,构建系统必须检测并解决重复问题.

Dependency resolution

When a project references two Library projects that both require the same jar file, the build system has to detect and resolve the duplication.

还要注意,从 r17 开始,libs 文件夹下的所有 jar 文件都会自动填充到项目的类路径中,您不再需要手动将它们添加到项目的构建路径中,在 r17 变更日志:

Also Note that since r17, all jar file under libs folder are automatically populated to project's classpath, you don't need manually add them to project's build path anymore, also mentioned in the r17 changelog:

项目具有源文件夹,以及库项目和 jar 文件依赖项.除了在 project.properties 中添加库项目作为依赖项之外,不需要其他设置,项目的类路径会自动填充:

Projects have source folders, as well as Library Project and jar file dependencies. With no other setup needed than adding Library Projects as a dependency in project.properties, a project’s classpath is automatically populated with:

  • 项目的 libs/*.jar 的内容
  • 图书馆项目的成果.
  • 图书馆项目的 libs/*.jar

希望这会有所帮助.

这篇关于使用 ActionBarSherlock &ViewPagerIndicator 同步不会编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆