0

I have added JakeWharton/ViewPagerIndicator by adding below statements to gradle.I am trying to use TabPageIndicator like this but it can't find import com.viewpagerindicator.TabPageIndicator although my gradle build fine after adding library.

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'
Android Developer
  • 9,157
  • 18
  • 82
  • 139
  • Are you sync after adding library? –  Apr 21 '15 at 12:55
  • @VAISAKHPVR yeah..gradle sync ran fine – Android Developer Apr 21 '15 at 12:55
  • how you added the library into android studio? –  Apr 21 '15 at 12:57
  • @VAISAKHPVR i have just added the above statements in gradle that should be enough to add library – Android Developer Apr 21 '15 at 12:58
  • i followed this link.. http://stackoverflow.com/questions/25702884/add-viewpagerindicator-to-android-studio – Android Developer Apr 21 '15 at 12:59
  • ok now try it by adding File ->Project Structute->app->dependency-> there you can add module dependency browse your library project and sync –  Apr 21 '15 at 13:01
  • @VAISAKHPVR dependencies already show 'com.viewpagerindicator:library:2.4.1@aar' – Android Developer Apr 21 '15 at 13:05
  • how you imported the library folder into your project is by File-> import module if it is add it into your project from project structure is it all in right way check your library that all file are there then once restart you studio it should show the classes of your library into your project –  Apr 21 '15 at 13:12
  • Try these: compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar' .For more details see @avianey's answer here in this link - http://stackoverflow.com/questions/21130003/using-viewpagerindicator-library-with-android-studio-and-gradle – Amrit Pal Singh Apr 21 '15 at 13:25

2 Answers2

1

Update

Library is available here where you can download the zip

https://github.com/JakeWharton/ViewPagerIndicator

and at the website for VierPagerIndicator:

http://viewpagerindicator.com/

To add this:

  1. Right click your Main Application ->New Module
  2. From the More modules section ->Import Existing Project
  3. Navigate to where you have downloaded, and extracted the zip file and select it.

This should import it and add it as a dependency for your project, unfortunately this did not get the desired project structure I wanted. So i copied the new module to the libs folder of my main module.

However this causes issues with gradle since now the project is linked incorrectly. So after i imported the new module and moved the project from a module within my main application i was prompted to add the library as a reference in settings.gradle which now looks like:

 include ':app',':ViewPagerIndicator'
 project(':ViewPagerIndicator').projectDir = new File('app/libs/ViewPagerIndicator')

And my Main apps build.gradle:

 apply plugin: 'com.android.application'

 android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.test.demo.myapplication"
        minSdkVersion 8
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
         release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
     }
 }

 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile 'com.android.support:appcompat-v7:22.0.0'
     compile project(":ViewPagerIndicator")
 }

Additionally my project structure is:

enter image description here

kandroidj
  • 13,784
  • 5
  • 64
  • 76
  • @BhuvneshVarma did you copy the source and add it to libs folder then reference it in your settings.gradle file? – kandroidj Apr 21 '15 at 13:05
  • which source do i need to copy in libs folder?I just added statements in question to build.gradle.. – Android Developer Apr 21 '15 at 13:13
  • @BhuvneshVarma see explanation above with how to add library project this has always worked for me – kandroidj Apr 21 '15 at 13:19
  • i am getting error "Error:Configuration with name 'default' not found." while building gradle – Android Developer Apr 21 '15 at 13:22
  • @BhuvneshVarma this is progress, what did you name the added module in the libs folder? – kandroidj Apr 21 '15 at 13:23
  • i renamed it as ViewPagerIndicator – Android Developer Apr 21 '15 at 13:23
  • +one for ur errort..but from where you downloaded zip file of ViewPagerIndicator?bcoz i downloaded from here-https://github.com/JakeWharton/ViewPagerIndicator and i don't see any build.gradle file in it – Android Developer Apr 21 '15 at 15:04
  • Correct @BhuvneshVarma this is why you need to download the zip and import project as existing project. which should create the build.gradle for you for the new module form Existing source – kandroidj Apr 21 '15 at 15:12
  • when i try to import project by clicking on "Import Exiting Project" and specifying the location of project it says "Specify location of Gradle or Android Eclipse Project".. – Android Developer Apr 21 '15 at 15:15
  • try using Right Click -> New ->Module ->More Modules ->Import Existing Project then click next and specify location to the library of the downloaded zip – kandroidj Apr 21 '15 at 15:19
0

enter image description here

Add your library module from project structure and sync