loeschg loeschg - 1 year ago 340
Android Question

Using ViewPagerIndicator library with Android Studio and Gradle

I'm trying to use Jake Wharton's ViewPagerIndicator library, but I'm unable to get it working with my Gradle project in Android Studio.

I add it as a dependency like so:

dependencies {
// ... other ommitted
compile 'com.viewpagerindicator:library:2.4.1'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.nineoldandroids:library:2.4.0'
// ...

but the project doesn't seem to recognize any components in the library. I'm wondering if there's a dependency issue with different support-v4 versions or something in nineoldandroids...?

Answer Source

A bit late to the party, but here:

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" }

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.

Make sure that the Maven Repo is listed above the mavenCentral() entry. Otherwise, it will first look in maven's central repository and find the wrong package.

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

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

We use it in our app if you'd like to see a working example:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download