简体   繁体   中英

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

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')
}

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

}

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

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM