Android Library Project using Android Studio

后端 未结 6 2062
离开以前
离开以前 2021-01-31 16:12

This question might have been answered somewhere but couldn\'t find the appropriate one.

I want to know how can I create a common utility library project in Android Stud

6条回答
  •  日久生厌
    2021-01-31 16:47

    Simplest way to do this :

    1. Right click on your opened project in Android Studio and select New > Module

    2. In the left Pane choose Android Library and click on next.

    3. Enter all details, untick Create Activity, Theme and all if not required.

    4. Choose API level same as your project and Next, Next, Next .

    Now you will see an another directory inside your project, build.gradle for library will be automatically configured for you.

    If your module/library name is "mylibrary",

    include ':mylibrary' 
    

    will be automatically added in settings.gradle file inside root directory of your project.

    Now open your main module and insert this line in dependency block :

    compile project(':mylibrary')
    

    If you want to use same library in other projects, you have to copy the library module to that particular project using File Explore and have to configure settings.gradle and main module's build.gradle manually.

提交回复
热议问题