How do I add a library project to Android Studio?

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

    A simple way to add a JAR file as a library to your Android Studio project:

    a) Copy your *.jar files

    b) Paste into the libs directory under your projects:

    Enter image description here

    c) Add to build.gradle:

    dependencies {
        ...
        compile files('libs/ScanAPIAndroid.jar', 'libs/ScanAPIFactoryAndroid.jar', .., ..)
    }
    

    b) If your project from example com.example.MYProject and libraries com.example.ScanAPI has the same namespace com.example, Android Studio will check your build and create all necessary changes in your project. After that you can review these settings in menu File -> Project Structure.

    c) If your project and libraries have a different namespace you have to right click on the library and select option "Add as Library" and select the type what you need.

    Remember the "Project structure" option is not doing any auto changes in "build.gradle" in the current version of Android Studio (0.2.3). Maybe this feature will be available in the next versions.

提交回复
热议问题