How do I add a library project to Android Studio?

前端 未结 30 3980
梦谈多话
梦谈多话 2020-11-21 04:24

How do I add a library project (such as Sherlock ABS) to Android Studio?

(Not to the old ADT Eclipse-based bundle, but to the new Android Studio.)

30条回答
  •  时光说笑
    2020-11-21 05:11

    Option 1: Drop Files Into Project's libs/directory

    The relevant build.gradle file will then update automatically.

    Option 2: Modify build.gradle File Manually

    Open your build.gradle file and add a new build rule to the dependencies closure. For example, if you wanted to add Google Play Services, your project's dependencies section would look something like this:

    dependencies {
         compile fileTree(dir: 'libs', include: ['*.jar'])
         compile 'com.google.android.gms:play-services:6.5.+'
       }
    

    Option 3: Use Android Studio's User Interface

    In the Project panel, Control + click the module you want to add the dependency to and select Open Module Settings.

    Enter image description here

    Select the Dependencies tab, followed by the + button in the bottom-left corner. You can choose from the following list of options:

    • Library Dependency
    • File Dependency
    • Module Dependency

    You can then enter more information about the dependency you want to add to your project. For example, if you choose Library Dependency, Android Studio displays a list of libraries for you to choose from.

    Once you've added your dependency, check your module-level build.gradle file. It should have automatically updated to include the new dependency.

    Source

提交回复
热议问题