AruLNadhaN
AruLNadhaN

Reputation: 2826

Can't add External Library in Android Studio?

I Added a External Library to my project by following this method. and tried this method too this method too. Gradle build got Finished and i got this line added to my build.gradle

compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.1'

Now i am trying to import this library in my class. But i can't do this. I took a look at the files and they are located in the build directory under the exploded-aar. so i added @aar to the compile line. Still there are no changes.

How can i import this library to my class or where i am going wrong?

Thanks in Advance

Upvotes: 1

Views: 4051

Answers (4)

JBaruch
JBaruch

Reputation: 22893

Well, you don't need to download anything or point your dependency to a file.

This dependency, as most of the dependencies you use, can automatically fetched from JCenter, biggest repository for Java and Android components.

All you need to do is:

  1. Add JCenter as your dependencies repository.
  2. Declare that you need the library-circular dependency. This can be found and copy/pasted from the file icon in particular package/version in JCenter.
  3. Resync your Android Studio project with your Gradle build file. This is the 'sync' button in Gradle pane in Android Studio.

Here's what your build.gradle should include:

repositories {
    jcenter()
}

dependencies {
    compile(group: 'com.github.castorflex.smoothprogressbar', name: 'library-circular', version: '1.0.1', ext: 'aar')
}

Upvotes: 7

swapnil karulkar
swapnil karulkar

Reputation: 29

in build. gradle put following code dependencies { compile fileTree (dir: 'libs', include: ['*.jar'])

}

Upvotes: 2

Ankit Arora
Ankit Arora

Reputation: 117

1.Put the jar file into the libs folder.

2.Right click it and hit 'Add as library'.

3.Ensure that compile files('libs/abcdef.jar') is in your build.gradle file and Finally add the dependencies.

Eg.

dependencies {

    compile fileTree(dir: '../jar', include: '*.jar')

    compile project(':pull-to-refresh')

    compile files('libraries/abcdef.jar')
}

Hope this helps :)

Upvotes: 0

Slay
Slay

Reputation: 231

Did you add the dependencies?

You can do so in the following way -

dependencies {
compile files('insert ParentFolder/external_library_name with the extension here')
}

Add it to build.gradle based in the app folder

Upvotes: 0

Related Questions