3

I have moved from Eclipse to Android Studio for android programming. I am having trouble importing my .jar files in Android Studio. I cannot seem to import any 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
donfuxx
  • 11,277
  • 6
  • 44
  • 76
Suman Palikhe
  • 357
  • 1
  • 4
  • 16

2 Answers2

5

Add the following in the build gradle file in the dependencies part:

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

the above assumes that the library is inside the libs folder of your project.

Alternatively you could also add the dependency like this by telling gradle a single jar file:

compile files('libs/yourlibrary.jar')

After having added this lines you should sync your project again and android studio should allow you now to import those classes from your library.

Update: Actually the jsoup library is available in the mavenCentral repository. So a nice way to include this dependency is:

 compile 'org.jsoup:jsoup:1.8.2'

or just do this to always take the latest version:

 compile 'org.jsoup:jsoup:+'

Note: you need to have mavenCentral repository added in the build grade if you do it like this:

 repositories {
     mavenCentral()
 }
donfuxx
  • 11,277
  • 6
  • 44
  • 76
1

compile 'org.jsoup:jsoup:+'

// worked for me.

arshad shaikh
  • 673
  • 8
  • 11