0

I have created an android application using maven-android-plugin, I want to use Android-ViewPagerIndicator and I've added dependency in the pom.xml.

<dependency>
  <groupId>com.viewpagerindicator</groupId>
  <artifactId>library</artifactId>
  <version>2.4.1</version>
  <type>apklib</type>
</dependency>

But my android application is giving compile errors if I use the classes from Android-ViewPagerIndicator.

TitlePageIndicator cannot be resolved to a type

I'm getting above error in eclipse.

Do I still need to download the library, import it to eclipse and reference it in the eclipse?

(Sorry if this is a stupid question, since this is my first Android-Maven Project)

Yasitha Waduge
  • 13,180
  • 5
  • 35
  • 42

2 Answers2

0

Eclipse's configuration ought to be changed in order to use the installed Maven, and its repository and settings instead of the embedded one. Go to "Window -> Preferences -> Maven -> Installations", add externally installed Maven to the list, and select it.

After this, right click on the Maven project -> Maven -> Update Project. Click "Select All" (right side) and make sure all options at the bottom of the dialog box are selected except "Offline". This should refresh your workspace with dependencies from your local Maven's repository.

Amir Keibi
  • 1,991
  • 28
  • 45
  • Thanks for the advice, Yes I followed your instructions and changed maven installation to external installation directory. But still my project shows compile error. I can see my .m2 folder and apk lib is copied. But when I download viewpagerindicator library and reference it in eclipse its not showing the error, but then there is no use of maven. :( – Yasitha Waduge Sep 02 '13 at 07:07
  • Thanks for the update, Still no luck, I did updating project, Now pom.xml shows an error. "dependency=[com.viewpagerindicator:library:apklib:2.4.1:compile] not found in workspace" When I download the library, import it to eclipse and once I reference it to my project, everything works fine.. :( – Yasitha Waduge Sep 04 '13 at 02:45
  • I just noticed something. Why your GAV coordinates have "library" in it? Shouldn't it be "com.viewpagerindicator:apklib:2.4.1:compile"? – Amir Keibi Sep 04 '13 at 17:24
  • Apklib support in Eclipse is not yet fully working with the m2e-android plugin... which is why you need to manually link it. – Manfred Moser Sep 05 '13 at 22:37
  • Apklib's are fully supported! https://code.google.com/p/maven-android-plugin/wiki/ApkLib – drewan50 Oct 24 '13 at 03:08
0

The trick is to configure/convert each library project to a Maven project as well. Once you do that your pom should have no trouble finding it.

Additionally, when you build using Maven.. first build each library project (mvn clean install) and then build the main solution.

drewan50
  • 294
  • 1
  • 7