Sunday 16 June 2013

How to do add external library file in Android Studio.



Here I am adding ksoap2.jar file for calling .net webservice. You can download this from
http://ksoap2-android.googlecode.com/svn/m2-repo/com/google/code/ksoap2-android/ksoap2-android-assembly/3.0.0/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar.
For adding ksoap2 file we have put that file in libs folder.project->libs.Open the libs folder in explorer and paste the ksoap2 jar file in it.Come to studio and refresh the project.we will see ksoap file in  libs folder.Now righrt click the ksoap file and select add as library option.then new create library window will come. Clcik on Ok Button.Now we can use this jar file for our application.also add  the below code in build.gradle file and rebuild the application
dependencies {
    compile files('libs/ksoap2-android-assembly-2.4-jar-with-dependencies.jar')
}


4 comments:

  1. Clcik on Ok.Now we can use this jar file for our application.also add the below code in build.gradle file and rebuild the application.

    ReplyDelete
  2. I add the external jar by adding compile files('libs/demo.jar') and i build the project, it works fine !
    But When I install the APK to emulator, I always got the error like following:

    07-31 11:09:13.959 1514-1514/com.demo.mobile E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.demo.util.CheckSum

    I lost the demo.jar on runtime
    Did you get the problem like this before ?

    Thanks

    P.S: I use Android Studio 0.2.2 with ADT 22

    ReplyDelete
  3. Continue the wonderful good article, I just read couple of articles about this web page and i believe that the blog is rattling intriguing and consists of sets of helpful information.

    ReplyDelete
  4. Thanks a lot from Colombia! ;)

    ReplyDelete