2

I'm trying to add external jars to my android project. these external jars are dependent on each other and some them are dependencies to another one so when there is a reference to a class which is located in another jar file android studio throws java.lang.NoClassDefFoundError for that class.

what's the right solution to use these kind of jars in an android project??

  compile files('libs/gt-shapefile-2.7.5.jar')
compile files('libs/gt-metadata-2.7.5.jar')
compile files('libs/gt-data-2.7.5.jar')
compile files('libs/gt-main-2.7.5.jar')
compile files('libs/gt-api-2.7.5.jar')
compile files('libs/gt-referencing-2.7.5.jar')
compile files('libs/vecmath-1.3.2.jar')
compile files('libs/commons-pool-1.5.4.jar')
compile files('libs/gt-opengis-2.7.5.jar')
compile files('libs/jsr-275-1.0-beta-2.jar')
compile files('libs/jts-1.11.jar')
compile files('libs/jdom-1.0.jar')
compile files('libs/jai_core-1.1.3.jar')
compile files('libs/hsqldb-1.8.0.7.jar')
compile files('libs/gt-epsg-hsql-2.7.5.jar')
alireza rahmaty
  • 576
  • 6
  • 16

1 Answers1

1

you can refer to this answer to get the right way to add jar libraries.

  1. First switch your folder structure from Android to Project. enter image description here enter image description here

  2. Now search for the libs folder inside app - build folder. enter image description here

  3. Once you have pasted the .jar file inside libs folder. Right click on the jar file and at end click on Add as library. This will take care of adding compile files('libs/library_name.jar') in build.gradle [You don't have to manually enter this in your build file]. enter image description here

    enter image description here

    Now you can start using the library in your project.

Zacktamondo
  • 1,891
  • 3
  • 17
  • 33