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

查看:104
本文介绍了使用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更改日志

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文件的Library项目时,构建系统必须检测并解决重复项。

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:


项目具有源文件夹,以及Library Project和jar文件依赖项。除了将Library Projects作为依赖项添加到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天全站免登陆