How can I use external JARs in an Android project?

前端 未结 12 1464
甜味超标
甜味超标 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 12:05

    If using Android Studio, do the following (I've copied and modified @Vinayak Bs answer):

    1. Select the Project view in the Project sideview (instead of Packages or Android)
    2. Create a folder called libs in your project's root folder
    3. Copy your JAR files to the libs folder
    4. The sideview will be updated and the JAR files will show up in your project
    5. Now right click on each JAR file you want to import and then select "Add as Library...", which will include it in your project
    6. After that, all you need to do is reference the new classes in your code, eg. import javax.mail.*

提交回复
热议问题