8

I've just switched from Eclipse to Android Studio, and I'm having some problems with a project of mine that uses ViewPagerIndicator

This is the Gradle code:

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.viewpagerindicator:library:2.4.1'
    compile 'com.android.support:support-v4:19.0.+'
    compile 'com.android.support:appcompat-v7:19.0.+'
}

When I try to build the project, Android Studio returns me this error:

LoadViewPagerTask.java
    Error:Error:line (30)error: package com.viewpagerindicator does not exist
    Error:Error:line (82)error: cannot find symbol class TitlePageIndicator
    Error:Error:line (82)error: cannot find symbol class TitlePageIndicator

In other words, the library was not imported. Any solution? Thank you for your attention.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Gnufabio
  • 1,505
  • 4
  • 16
  • 26
  • possible duplicate of [Using ViewPagerIndicator library with Android Studio and Gradle](http://stackoverflow.com/questions/21130003/using-viewpagerindicator-library-with-android-studio-and-gradle) – kar Mar 02 '14 at 10:55
  • nop, in that post there isn't a solution for my problem – Gnufabio Mar 02 '14 at 10:57

3 Answers3

18

Jake Wharton hasn't released it in maven as an aar. There's a group though that has made an aar of it available through their server, you can set it up like this in your build.gradle:

Add this to your source repositories after you declare your plugins:

repositories {
    maven { url "http://dl.bintray.com/populov/maven" }
    mavenCentral()
}

This will source their maven repo, which contains a packaged aar that they put together. Once that's done, you can simply add this line to your dependencies and everything should work once you sync your project with your gradle files.

dependencies {
    // ...
    compile 'com.viewpagerindicator:library:2.4.1@aar'
    // ...
}

We use it in our app if you'd like to see a working example: https://github.com/pandanomic/SUREwalk_android/blob/master/surewalk/build.gradle

EDIT: Android Studio generates two build.gradle files for projects now, make sure you put this in the right one!

Zac Sweers
  • 3,101
  • 2
  • 18
  • 20
  • ive tried but i get similar error to other pages - Artifact 'com.view...:library.aar' no found. looked at your build gradle and copied it over almost exactly but no luck - but i also noticed ur build.gradle doesnt even have compile 'com.android.support:support-v4:19.0.1' so are u even using the support lib or is it just coming through from other libs automatically? – trippedout Mar 27 '14 at 20:29
  • The support lib gets brought in via actiobarsherlock. I'll try the repo stuff later tonight or tomorrow though, it's possible they've moved it. Have you made sure you're putting it in the right build file? See my edit – Zac Sweers Mar 27 '14 at 21:33
  • The module that requires it, be it your app or library – Zac Sweers Mar 31 '14 at 20:59
  • 12
    Got it to work. In the root build.gradle allprojects { repositories { maven { url "http://dl.bintray.com/populov/maven" } mavenCentral() } } and in the app's build.gradle you can set the compile aar. – level32 Apr 01 '14 at 16:27
  • It's important to note that `maven { url "dl.bintray.com/populov/maven"; }` has to go *before* mavenCentral() so that it overrides the entry there. – John Hamelink Jun 14 '14 at 16:31
  • 1
    I have no luck and still get error Error:Artifact 'library.aar (com.viewpagerindicator:library:2.4.1)' not found. Searched in the following locations: https://jcenter.bintray.com/com/viewpagerindicator/library/2.4.1/library-2.4.1.aar. Already try @level32 suggestion – Plugie Feb 07 '15 at 06:02
6

You can't use it with gradle.

compile 'com.viewpagerindicator:library:2.4.1'

Check in Maven:

http://search.maven.org/#artifactdetails%7Ccom.viewpagerindicator%7Clibrary%7C2.4.1%7Capklib

It hasn't an aar format. It has a apklib format.

    <artifactId>library</artifactId>
    <name>Android-ViewPagerIndicator</name>
    <packaging>apklib</packaging>

As alternative you can build it locally, or you use aar provided by third parties

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0

You can use jitpack.io with

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
    google()
    jcenter()
}

and

implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
EpicPandaForce
  • 79,669
  • 27
  • 256
  • 428