Adding external library in Android studio

前端 未结 19 1086
面向向阳花
面向向阳花 2020-11-22 05:51

I want to add external library https://github.com/foursquare/foursquare-android-oauth to my Android application (I use Android Studio, the instructions provided by lib autho

相关标签:
19条回答
  • 2020-11-22 06:12
    1. In the repositories section of the project's build.gradle add the following:
    flatDir { dirs 'aars' } 
    
    1. In your dependencies section of build.gradle add the following:

    compile '[group id]:[artifact id]:[version]@aar'

    replacing [group id] etc with the various lib attributes

    1. create a sub directory aars under your project directory

    2. Copy the [youlibrary].aar to the subdirectory created in 3. above.

    3. Build & Enjoy!

    0 讨论(0)
  • 2020-11-22 06:14

    Android studio doesn't use Maven, it use Gradle, you can open your build.gradle the route should be: /app/build.gradle and add the Gradle dependency that shows on the repo:

    The build.gradle has a dependencies section:

    dependencies {
        //here add your dependency
    }
    

    The repo says that you need to add this dependency:

    compile 'com.foursquare:foursquare-android-oauth:1.0.3'
    

    only add that line to your dependencies on buil.gradle, save the file, and android will rebuild the project, that's all

    0 讨论(0)
  • 2020-11-22 06:16

    There are some changes in new gradle 4.1

    instead of compile we should use implementation

    implementation 'com.android.support:appcompat-v7:26.0.0'

    0 讨论(0)
  • 2020-11-22 06:17

    Try one of these approaches:

    Approach 1)

    1- Choose project view

    2- Copy your JAR file in app -> lib folder

    3- Right click on your JAR file and choose add as library

    4- Check it in build.gradle


    Approach 2)

    1- File -> New -> New Module

    2- Import .JAR/.AAR Package

    3- Browse your JAR File

    4- Finish

    5- File -> Project Structure -> Dependencies

    6- You should click on + button and then click on Module Dependency

    7- You will see your library here

    8- choose your library and click ok

    9- Then, you will see that your library is added.


    For first two approaches, you need a JAR file. You can search http://search.maven.org/ to find JAR files that are related to Android. For example, this is the search result for jdom in this link


    Approach 3) Android is using http://jcenter.bintray.com/ as remote library. For example, this is the search result for jdom in the link.

    To add a library in this approach, please follow these steps:

    1- File -> Project Structure -> Dependencies

    2- Click on + button and choose library dependency

    3- find your library and select it, then click OK.


    I hope it helps.

    0 讨论(0)
  • For the simplest way just follow these steps

    1. Go to File -> New -> Import Module -> choose library or project folder

    2. Add library to include section in settings.gradle file and sync the project (After that you can see new folder with library name is added in project structure)

      include ':mylibraryName'

    3. Go to File -> Project Structure -> app -> dependency tab -> click on plus button

    4. Select module dependency -> select library (your library name should appear there) and put scope (compile or implementation)

    5. Add this line in build.gradle in app level module in dependency section

      implementation project(':mylibraryName')

    0 讨论(0)
  • 2020-11-22 06:20

    Adding library in Android studio 2.1

    Just Go to project -> then it has some android,package ,test ,project view
    

    Just change it to Project View

    under the app->lib folder you can directly copy paste the lib and do android synchronize it. That's it

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