Add ViewPagerIndicator to Android Studio

前端 未结 5 959
余生分开走
余生分开走 2020-11-30 21:40

i\'m trying to get Jake Wharton\'s ViewPagerIndicator working with Android Studio but unfortunately it won\'t work.
I downloaded the .aar file from here and included it

5条回答
  •  北海茫月
    2020-11-30 22:17

    UPDATE

    Based on the answer given by Jürgen 'Kashban' Wahlmann, it is now possible to add ViewPagerIndicator via gradle:

    Top Level Build.gradle:

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

    App's build.gradle:

    compile 'com.viewpagerindicator:library:2.4.1@aar'
    

    Also, based on the answer given by Enrico Susatyo now it seems possible to download the library from Jitpack maven repositories. Do it as follows:

    In root build.grade:

    allprojects {
            repositories {
                ...
                maven { url "https://jitpack.io" }
            }
        }
    

    In project build.grade:

    dependencies {
                compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
        }
    

    ------------

    To use Android-ViewPagerIndicator in Android Studio, you can’t download it from gradle. Instead, you must import the library as an “Existing Project” to your current one.

    Follow these steps:

    #1 Download source code from GitHub.

    #2 In your Android Studio Project: File -> Project Structure -> add (+ symbol) -> Import Existing Project. Import just the folder called ”library”, not the entire project (leave the import options as Android Studio suggests).

    # 3 If the "compileSdkVersion" specified in your build.gradle doesn’t match with the one specified in the Android-ViewPagerIndicator project, change the second one. The same apply with any other property, such as "minSdkVersion" or even the current support library.

    # 4 Add Android-ViewPagerIndicator project as a dependency to your build.gradle module:

    dependencies {
        compile project(':library')
    }
    

    # 5 Sync project with gradle files.

提交回复
热议问题