Using ViewPagerIndicator library with Android Studio and Gradle
Solution 1
I just pushed a version inside maven central so you only need to add that dependency :
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
And declare maven central like this :
repositories {
mavenCentral()
}
Hope it helps...
Solution 2
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" }
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.
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:
https://github.com/pandanomic/SUREwalk_android/blob/master/surewalk/build.gradle
Solution 3
I'm using gradle 0.10.+ with Android Studio 0.8.2 and the accepted answer didn't work for me. These are the slight changes I had to do in order to get ABS working in my project:
In the top level build.gradle
file of your project add the maven repository in the allprojects
config like this:
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
}
And in the module's build.gradle
file add the dependency without the @aar
:
dependencies {
// ...
compile 'com.viewpagerindicator:library:2.4.1'
// ...
}
Solution 4
Jitpack.io is great for this situation.
First, add the following repository:
repositories {
// ...
maven { url "https://jitpack.io" }
}
Then, just add the dependency pointing to the GitHub repo:
dependencies {
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
}
Solution 5
Add this to your dependencies in your app module's build.gradle file like so:
dependencies {
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
...
}
![loeschg](https://i.stack.imgur.com/VxL0m.jpg?s=256&g=1)
loeschg
Updated on November 02, 2020Comments
-
loeschg over 3 years
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...?
-
loeschg over 10 yearsThanks, @pyus13. Yeah, that sync project button is my first step when adding a new dependency. That wasn't the issue. I updated my question.
-
loeschg over 10 yearsYeah, this is a possibility. There's a pull request open to update the v4 support library (github.com/JakeWharton/Android-ViewPagerIndicator/pull/271). Doesn't look like this project is being actively maintained... :(
-
Piyush Agarwal over 10 years@loeschg i did not find that jackwarton has moved viewpagerindicator in gradle. It might be a problem.
-
Eugen Martynov over 10 yearsHey, but ViewPagerInidicator is android library. It means if they use maven then it is most probably apklib artefact and gradle works with war artefact only
-
Ferran Maylinch over 10 yearsThanks! Just wanted to remark that bintray repo must be above mavenCentral(). You can read this: blog.haunted-soft.com/2013/10/…
-
Luke Sleeman over 10 yearsThis no longer seems to work - I followed the steps and when android studio refreshes the project I get "Gradle 'XYZ' project refresh failed: Artifact 'com.viewpagerindicator:library:2.4.1:library.aar' not found.
-
Luke Sleeman over 10 yearsAfter lots of mucking around I have found recent versions of android studio produce projects with two gradle files - one inside at app/build.gradle and one at /build.gradel - the one in the root directory is where you can add configuration options common to all sub-projects/modules. You need to put: allprojects { repositories { maven { url "dl.bintray.com/populov/maven" } mavenCentral() } } in the top level build.gradle for it to work
-
Zac Sweers about 10 years@Johan I included a link at the bottom of my post to an example
-
Zac Sweers about 10 yearsThat's odd. I just used the same method to add it to another project earlier this week and it still works fine for me :/
-
Johan about 10 yearsI did see the example. I take it the example are the two files from root and from app. In the app build.gradle I added repositories { maven { url "dl.bintray.com/populov/maven" }mavenCentral()} and in dependencies { compile 'com.viewpagerindicator:library:2.4.1@aar', I am probably missing something, since I get the error: Error:Artifact 'com.viewpagerindicator:library:2.4.1:library.aar' not found. (I'm using A.S. 5.8)
-
Zac Sweers about 10 yearsWait, were you meaning that doesn't work or that it's just not a comprehensive example?
-
Johan about 10 yearsThe example does not work with android studio 5.8 gradle 0.9.+, but it is comprehensive.
-
Johan about 10 yearsWhat gradle and Android Studio versions do you use?
-
Zac Sweers about 10 years0.9.+ on an older project (but it still works there). Maybe try upgrading to 0.10.+? Here's a working example with that from a gradle migration i did for a friend's project earlier this week: github.com/pandanomic/utexas-utilities/blob/master/build.gradle
-
Johan about 10 yearsThanks for trying to help me, changed it, but I still do not get it working, still it complains on "Error:Artifact 'com.viewpagerindicator:library:2.4.1:library.aar' not found.". I uploaded a version of my files here: textuploader.com/r346
-
Oleg Vaskevich about 10 years@Johan: I had the same error. I almost got it to work using
compile group: 'com.viewpagerindicator', name: 'library', version: '2.4.1', ext: 'apklib'
, but then ran into an issue with the duplicateAndroidManifest.xml
file. -
Johan about 10 yearsI got it working.. but not by using maven. I created a folder named libraries in my root and there I put the source code. That code I made sure worked as a library. Then I importet that as a module.
-
Ricardo Pessoa about 10 yearsattention now the dependency is compile 'com.viewpagerindicator:library:2.4.1' [reference:]mvnrepository.com/artifact/com.viewpagerindicator/library/2.4.1
-
John Hamelink about 10 yearsThis is no longer correct advice, as the @aar suffix is no longer needed.
-
Zac Sweers almost 10 years@RicardoPessoa You are mistaken. The whole reason it's listed with an aar is because the one in mavencentral is an apklib and doesn't have one. By specifying the bintray repo before mavenCentral(), it will use the aar one there instead. Also, to the person that edited it without checking first, please be more thorough before making edits.
-
Zac Sweers almost 10 years@OlegVaskevich you are trying to compile the wrong library. You need to use the aar in the bintray repo specified in the answer above. There's a fair amount of misinformation in this thread not being helped by people making bad edits to my answer.
-
Lv.BeLeCk over 9 yearsAs of today you should remove the "@aar", gradle cannot find it but it works with "compile 'com.viewpagerindicator:library:2.4.1'"
-
Zac Sweers over 9 years@Lv.BeLeCk this is not correct. As you can see in the below link, the aar is still there. dl.bintray.com/populov/maven/com/viewpagerindicator/library/…
-
trippedout over 9 yearsalso note if you are using the support library elsewhere and have it added to your dependencies, you might get a weird error since viewpager also brings in its own version of support v4. refer to this link - stackoverflow.com/questions/20989317/…
-
voghDev over 9 yearsBrilliant. I could make it work just now. I confirm that the dependency finishes in 2.4.1@aar, that's the correct version to make it work.
-
Greg Ennis over 9 yearsThank you. I did not want to add some random maven repository to my build script. This much better.
-
Sam about 9 yearsDidn't work for me; got
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
. -
Sam about 9 yearsJust to clarify,
library-2.4.1.aar
needs to be put in your module'slibs
directory, which you should create if it doesn't already exist. -
rrrocky about 9 yearsI added the said dependency but it fails to resolve it on gradle build. Exact error:
Failed to resolve: fr.avianey.com.viewpagerindicator:library:2.4.1
Any reason why? -
avianey about 9 yearsdid you add the repository in the right section... I mean not in the plugin repositories...
-
rrrocky about 9 years
-
avianey about 9 yearsjust put it outside of the android closure... at the same level as the apply plugin
-
rrrocky about 9 yearsError:(4, 0) Gradle DSL method not found: 'compile()' Possible causes:The project 'Pigen' may be using a version of Gradle that does not contain the method. Gradle settingsThe build file may be missing a Gradle plugin. Apply Gradle plugin What do I do now? Which plugin should I use?
-
rrrocky about 9 yearsAm I missing something here?
-
Mark about 9 yearsfr.avianey.com.viewpagerindicator:library:2.4.1@aar - you're missing the @aar
-
friederbluemle over 8 yearsThis did not work for me, as the pom file seems to have a dependency on
com.google.android:android
.Variant Debug has a dependency on version 4.1.1.4 of the legacy com.google.android Maven artifact, which corresponds to API level 15.
-
friederbluemle over 8 yearsExplicitly excluding transitive dependencies fixed the build:
compile('fr.avianey.com.viewpagerindicator:library:2.4.1') { transitive = false; }
-
moDev over 8 yearsThis doesn't work in 4.4 and it throws
Didn't find class com.viewpagerindicator.CirclePageIndicator
-
avianey over 8 yearsthat's not related to the android version, whether yuor sdk version or your project setup
-
Muhammad over 8 yearsSaved the day thanks :) I'll post your answer somewhere else stackoverflow.com/questions/25702884/….
-
avianey over 8 yearsupdate top 2.4.1.1 which switch from deprecated FloatMath to Math so you can use proguard with latest SDK
-
MiguelHincapieC about 8 yearsyou should use this answer at 2016
-
RoCkDevstack about 8 years@Juan Andres - Is it ok if I take the gradle only?
-
Govinda Paliwal over 7 yearsnot working : Error:Packaging for dependency com.viewpagerindicator:library:2.4.1 is 'apklib' and is not supported. Only 'aar' libraries are supported.
-
user2408952 over 7 yearsIdd this is the correct way to do it. Since it goes directly to the source project on GitHub, skipping 3th party sites.