Home » Android » Failed to build Android app (refer to both ActionBarSherlock & ViewPagerTabs) with Ant

Failed to build Android app (refer to both ActionBarSherlock & ViewPagerTabs) with Ant

Posted by: admin June 15, 2020 Leave a comment


I have one Android app which uses ActionBarSherlock & ViewPagerTabs. I use Eclipse to write and build it, and it just works well until I try to build it with Ant. Here’s what I did:

  1. go to ActionBarSherlock folder, run “android update lib-project –path .”
  2. go to ViewPagerTabs folder, run “android update lib-project –path .” too
  3. go to app folder, run “android update project –path .”
  4. run “and debug” under app folder, and I got following errors:


[javac] C:\Android\TestApp\src\com\test\App\TestActivity.java:46: cannot find symbol
[javac] symbol  : method getSupportActionBar()
[javac] location: class com.test.App.TestActivity
[javac]         final ActionBar ab = getSupportActionBar();
[javac]                              ^

So question NO. 1: I have correct library references in app’s project.properties, and ActionBarSherlock & ViewPagerTabs could be built successfully, why do I still get these errors?

There’s a workaround for this issue — copy all classes.jar under library’s bin folder into app’s libs folder, and run “ant debug” again. But I need to delete these .jar files under app’s libs folder after all .java files of app could be compiled.

Running “ant debug” again after this, I will get following errors:

[dx] processing archive C:\Android\ActionBarSherlock\library\bin\classes.jar...
[dx] ignored resource META-INF/MANIFEST.MF
[dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl.class...
[dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl.class...
[dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.class...
[dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs.class...
[dx] processing android/support/v4/app/ActionBar$LayoutParams.class...
[dx] processing android/support/v4/app/ActionBar$OnMenuVisibilityListener.class...
[dx] processing android/support/v4/app/ActionBar$OnNavigationListener.class...
[dx] processing android/support/v4/app/ActionBar$Tab.class...
[dx] processing android/support/v4/app/ActionBar$TabListener.class...
[dx] processing android/support/v4/app/ActionBar.class...
[dx] processing android/support/v4/app/ActivityCompatHoneycomb.class...
[dx] java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityCompatHoneycomb;
[dx]    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[dx]    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[dx]    at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[dx]    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[dx]    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[dx]    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[dx]    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[dx]    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[dx]    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[dx]    at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[dx]    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[dx]    at com.android.dx.command.dexer.Main.run(Main.java:206)
[dx]    at com.android.dx.command.dexer.Main.main(Main.java:174)
[dx]    at com.android.dx.command.Main.main(Main.java:95)
[dx] 1 error; aborting

My question NO.2 is: how can I fix this issue?


How to&Answers:

I finally resolve it myself. I find that there’s a android-support-v4.jar in ViewPagerTabs’ libs folder. The solution is — deleting this android-support-v4.jar, then make ViewPagerTabs depend on ActionBarSherlock (because ActionBarSherlock actually have one copy of Support Package).

I hope it’s useful for people who wants to use ActionBarSherlock & ViewPagerTabs in one application and use Ant to built his/her application. Good luck.


You stated its because both library have android-support-v4.jar. See @porter-liu answer for non-maven builds.

For people using maven, set your ViewPager dependancy as:


The exclusion tag stops the double import fixing the issue.


When you update lib-project, you’re updating the project so that it compiles as a library. There’s a separate step to update your main project so that it sees the library it requires.

For each library project you’re going to use, run

android update project –library ../pathToTheLibrary