How do I add a library project to Android Studio?

前端 未结 30 3894
梦谈多话
梦谈多话 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:04

    Editing library dependencies through the GUI is not advisable as that doesn't write those changes to your build.gradle file. So your project will not build from the command-line. We should edit the build.gradle file directly as follows.

    For instance, given to following structure:

    MyProject/

    • app/
    • libraries/
      • lib1/
      • lib2/

    We can identify three projects. Gradle will reference them with the following names:

    1. :app
    2. :libraries:lib1
    3. :libraries:lib2

    The :app project is likely to depend on the libraries, and this is done by declaring the following dependencies:

    dependencies {
        compile project(':libraries:lib1')
    }
    

提交回复
热议问题