0

I am a freshman in android development and want to use webservice by some jars.(The webservice has been written and publish). Then I use Ksoap.jar and Jsoup.jar. In android studio. I try to import them. It shows successful but I still cannot use the classes in the jars.

The build.gradle shows below:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile files('libs/ksoap2-android-3.4.0.jar')
    compile files('libs/jsoup-1.8.3-sources.jar')
}

But in my activity, I still cannot import them. How can I solve this problem? It drives me mad.

Slava Vedenin
  • 58,326
  • 13
  • 40
  • 59
Brian Zhou
  • 11
  • 2
  • is this the master Build.Gradle file or the App one? – Droid Chris Feb 03 '16 at 23:04
  • Did you execute "Sync gradles"? It will be exists in [Tools]-[Android]-[Sync Project with Gradle Files]. – Kae10 Feb 04 '16 at 00:36
  • Also, check library dependencies of project at [File]-[Project Structure]-[Modules_app]-[Dependencies]. If your jar files are not exists at [Dependencies], you can't refer your custom libraries. – Kae10 Feb 04 '16 at 00:39
  • It is display in the Dependencies. But I still cannot use the class in the jar. For example, I type SoapObject(a class in KSOAP) and use alt+enter. Nothing adding on the top. How to do next step? – Brian Zhou Feb 04 '16 at 14:18

1 Answers1

0

You don't need

compile files('libs/ksoap2-android-3.4.0.jar')
compile files('libs/jsoup-1.8.3-sources.jar')

As long as you have those jar files in the libs folder, this gradle line will include them in your project.

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

It says "for every jar file in the libs/ directory, compile it." Having those two additional lines is redundant.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245