How to add .jar files to Android Studio
I have switched from Eclipse to Android Studio for Android programming. I am having trouble importing my .jar files into Android Studio . I am unable to import files from my jsoup package.
Error:(6, 17) error: package org.jsoup does not exist
Error:(7, 23) error: package org.jsoup.nodes does not exist
source to share
Add the following to your gradle build file under dependencies:
compile fileTree(dir: 'libs', include: '*.jar')
the above assumes the library is inside libs
your project folder .
Alternatively, you can also add a dependency like this by giving gradle one jar file:
compile files('libs/yourlibrary.jar')
After adding these lines, you should sync your project again and android studio should let you import these classes from your library.
Refresh . In fact, the jsoup library is available in the mavenCentral repository. So a good way to enable this dependency is:
compile 'org.jsoup:jsoup:1.8.2'
or just do this to always use the latest version:
compile 'org.jsoup:jsoup:+'
Note: you need to add mavenCentral repository to your build class if you do it like this:
repositories {
mavenCentral()
}
source to share