相关疑难解决方法(0)

本地aar库的传递依赖性

我们正在为我们的API创建一些库,我们将使外部开发人员的生活更轻松.

因此,我们创建了新的库项目,并将Retrofit和其他一些库作为依赖项.

dependencies {
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:retrofit:2.0.1'
    compile 'com.squareup.retrofit2:converter-gson:2.0.1'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
}
Run Code Online (Sandbox Code Playgroud)

现在,当我们构建它时,它会生成aar文件.

但是现在当我们将aar文件放到libs目录并将其设置为依赖项时,我们仍然必须在用户的build.gradle文件中放置相同的依赖项,这很糟糕.它应该来自图书馆,对吧​​?

repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile(name: 'ourlibrary', ext: 'aar') {
        transitive = true;
    }
}
Run Code Online (Sandbox Code Playgroud)

如何transitive = true上班?

android android-gradle-plugin aar

33
推荐指数
1
解决办法
7596
查看次数

标签 统计

aar ×1

android ×1

android-gradle-plugin ×1