How can I use external JARs in an Android project?

前端 未结 12 1479
甜味超标
甜味超标 2020-11-21 11:40

I have created an Android project and added an external JAR (hessian-4.0.1.jar) to my project. I then added the JAR to the build path and checked it off in Order and Export.

12条回答
  •  悲哀的现实
    2020-11-21 11:53

    If you are using gradle build system, follow these steps:

    1. put jar files inside respective libs folder of your android app. You will generally find it at Project > app > libs. If libs folder is missing, create one.

    2. add this to your build.gradle file your app. (Not to your Project's build.gradle)

      dependencies {
          compile fileTree(dir: 'libs', include: '*.jar')
          // other dependencies
      }
      

      This will include all your jar files available in libs folder.

    If don't want to include all jar files, then you can add it individually.

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

提交回复
热议问题