Adding external library in Android studio

前端 未结 19 1088
面向向阳花
面向向阳花 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:30

    A late answer, although I thought of giving an in-depth answer to this question. This method is suitable for Android Studio 1.0.0 and above.

    STEPS

    1. First switch your folder structure from Android to Project.

    1. Now search for the libs folder inside app - build folder.

    1. 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].

    Now you can start using the library in your project.

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

    SIMPLE STEPS TO ADD ANY LIBRARY IN ANDROID STUDIO:

    1. Copy the file in question from any folder in your computer (eg. C:/documents/xyz.jar"), then go to Android Studio and right-click the Project Library folder and select paste.

    2. Now, right click on the newly added Library file and select the option "add as Library"

    D.O.N.E

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

    To reference an external lib project without copy, just do this: - Insert this 2 lines on setting.gradle:

      include ':your-lib-name'
      project(':your-lib-name').projectDir = new File('/path-to-your-lib/your-lib-name)
    

    Insert this line on on dependencies part of build.gradle file:

    compile project(':your-lib-name')
    

    Sync project

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

    Any other way to import this lib? I can simply copy-paste source code into my source or create JAR out of it?

    Complete Steps for importing a library in Android Studio 1.1

    1. Goto File -> Import Module.
    2. Source Directory -> Browse the project path.
    3. Specify the Module Name
    4. Open build.gradle (Module:app) file
    5. Add the following line with your module name

      compile project(':internal_project_name')

    Taken from: how to add library in Android Studio

    0 讨论(0)
  • 2020-11-22 06:35
    1.Goto File -> New -> Import Module
       2.Source Directory -> Browse the project path.
       3.Specify the Module Name – it is used for internal project reference.
    

    Open build.gradle (Module:app) file.

     implementation project(':library')
    
    0 讨论(0)
  • 2020-11-22 06:38

    Three ways in android studio for adding a external library.

    1. if you want to add libarary project dependency in your project :

      A. In file menu click new and choose import module choose your library project path and click ok, library project automatically add in your android studio project .

      B. Now open your main module(like app) gradle file and add project dependency in dependency section dependencies {

      compile project(':library project name')

    2. if you want to add jar file : A. add jar file in libs folder. B. And Add dependency

      compile fileTree(dir: 'libs', include: '*.jar') // add all jar file from libs folder, if you want to add particular jar from libs add below dependency.

      compile files('libs/abc.jar')

    3. Add Dependency from url (recommended). like

      compile 'com.mcxiaoke.volley:library-aar:1.0.0'

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