Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewPagerIndicator dependency with Gradle and Android Studio

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.

like image 378
Gnufabio Avatar asked Mar 02 '14 10:03

Gnufabio


2 Answers

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!

like image 174
Zac Sweers Avatar answered Oct 25 '22 10:10

Zac Sweers


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

like image 22
Gabriele Mariotti Avatar answered Oct 25 '22 10:10

Gabriele Mariotti