简体   繁体   English

如何将.aar文件添加为Android库模块中的依赖项

[英]How to add .aar file as a dependency in a Android library module

I have .aar(MyLib.aar) file and i want to create a new android library (MyNewLib.aar) which is dependent on MyLib.aar 我有.aar(MyLib.aar)文件,我想创建一个新的Android库(MyNewLib.aar),它依赖于MyLib.aar

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories{
    flatDir{
        dirs 'libs'
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile(name:'mylib', ext:'aar')

}

When the build is completed the classes that are references to MyLib.aar, are not in the newly created MyNewLib.aar 构建完成后,引用MyLib.aar的类不在新创建的MyNewLib.aar中

i have checked this one 我检查过这个

How to add .aar dependency in library module? 如何在库模块中添加.aar依赖?

it doesn't work 它不起作用

put your aar file in libs folder then right click on that file and choose add as library and then sync now. 将您的aar文件放在libs文件夹中,然后右键单击该文件并选择add as library,然后立即同步。 it will be added to your project. 它将被添加到您的项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM