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

后端 未结 23 2123
故里飘歌
故里飘歌 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:17

    Please follow below steps to get it working ( I have tested it up to Android Studio 2.2)

    Lets say you have kept aar file in libs folder. ( assume file name is cards.aar )

    then in app build.gradle specify following and click sync project with Gradle files. Open Project level build.gradle and add flatDir{dirs 'libs'} like did below

    allprojects {
       repositories {
          jcenter()
          flatDir {
            dirs 'libs'
          }
       }
    }
    

    and now open app level build.grdle file and add .aar file

        dependencies {
           implementation(name:'cards', ext:'aar')
    }
    

    If everything goes well you will see library entry is made in build -> exploded-aar

    Also note that if you are importing a .aar file from another project that has dependencies you'll need to include these in your build.gradle, too.

提交回复
热议问题