How to manually include external aar package using new Gradle Android Build System

后端 未结 23 2140
故里飘歌
故里飘歌 2020-11-22 03:58

I\'ve been experimenting with the new android build system and I\'ve run into a small issue. I\'ve compiled my own aar package of ActionBarSherlock which I\'ve called \'act

23条回答
  •  不知归路
    2020-11-22 04:12

    There are 2 ways:

    The first way

    1. Open your Android Studio and navigate to the Create New Module window by File -> New -> New Module

    1. Select the Import .JAR/.AAR Package item and click the Next button

    2. Add a dependency in the build.gradle file that belongs to your app module.

        dependencies {
            ...
            implementation project(path: ':your aar lib name')
        }
    

    That's all.

    The second way

    1. Create a folder in libs directory, such as aars.

    2. Put your aar lib into the aars folder.

    3. Add the code snippet

    repositories {
        flatDir {
            dirs 'libs/aars'
        }
    }
    

    into your build.gradle file belongs to the app module.

    1. Add a dependency in the build.gradle file that belongs to your app module.
    dependencies {
        ...
        implementation (name:'your aar lib name', ext:'aar')
    }
    

    That's all.

    If you can read Chinese, you can check the blog 什么是AAR文件以及如何在Android开发中使用

提交回复
热议问题