Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ActionBarSherlock & ViewPagerIndicator Synchronously Will Not Compile

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.

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

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 :)

like image 579
TJ Biddle Avatar asked Apr 19 '12 20:04

TJ Biddle


1 Answers

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

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:

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.

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:

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:

  • The content of the project’s libs/*.jar
  • The output of the Library Projects.
  • The Library Projects’ libs/*.jar

Hope this helps.

like image 50
yorkw Avatar answered Oct 05 '22 22:10

yorkw