importing jar libraries into android-studio

后端 未结 13 1531
孤独总比滥情好
孤独总比滥情好 2020-11-29 01:32
android-studio 0.2.7
Fedora 18

Hello,

I am trying to add the jtwitter jar to my project.

First I tried doing the following:

相关标签:
13条回答
  • 2020-11-29 02:06

    There are three standard approaches for importing a JAR file into Android studio. The first one is traditional way, the second one is standard way, and the last one is remote library. I explained these approaches step by step with screenshots in this link:

    https://stackoverflow.com/a/35369267/5475941.

    I hope it helps.

    0 讨论(0)
  • 2020-11-29 02:15

    I see so many complicated answer.

    All this confused me while I was adding my Aquery jar file in the new version of Android Studio.

    This is what I did :

    Copy pasted the jar file in the libs folder which is visible under Project view.

    And in the build.gradle file just added this line : compile files('libs/android-query.jar')

    PS : Once downloading the jar file please change its name. I changed the name to android-query.jar

    0 讨论(0)
  • 2020-11-29 02:16

    In the project right click

    -> new -> module
    -> import jar/AAR package
    -> import select the jar file to import
    -> click ok -> done
    

    You can follow the screenshots below:

    1:

    2:

    3:

    You will see this:

    0 讨论(0)
  • 2020-11-29 02:16

    This is how you add jar files from external folders

    1) Click on File and there you click on New and New Module

    2) New Window appears ,,There you have to choose the Import .JAR/.AAR package .

    3) Click on the path option at the top right corner of the window ...And give the whole path of the JAR file .

    4)click on finish.

    Now you have added the Jar file and You need to add it in the dependency for your application project

    1)Right click on app folder and there you have to choose Open Module Settings or F4

    2)Click on dependency at the top right corner of the current window .

    3)Click on '+' symbol and choose 'Module Dependency' and It will show you the existed JAR files which you have included in your project ...

    Choose the one you want and click 'OK/Finish'

    Thank you

    0 讨论(0)
  • 2020-11-29 02:18

    Updated answer for Android Studio 2

    The easy and correct way to import a jar/aar into your project is to import it as a module.

    New -> Module

    Right click on the main project and New -> Module

    Select Import .JAR/.AAR Package

    Import .JAR/.AAR Package

    Select the .JAR/.AAR file and put a module name

    Select the .JAR/.AAR file

    Add the module as a dependency

    Add the module as a dependency

    0 讨论(0)
  • 2020-11-29 02:21

    This is the way I just did on Android Studio version 1.0.2

    • I have created a folder libs in [your project dir]\app\src
    • I have copied the jtwitter.jar (or the yambaclientlib.jar) into the [your project dir]\app\src\libs directory
    • The following the menu path: File -> Project Structure -> Dependencies -> Add -> File Dependency, Android Studio opens a dialog box where you can drag&drop the jar library. Then I clicked the OK button.

    At this point Gradle will rebuild the project importing the library and resolving the dependencies.

    0 讨论(0)
提交回复
热议问题