【发布时间】:2015-11-06 16:35:59
【问题描述】:
当我的 AAR 库已经使用这些依赖项时,为什么 gradle 强制我向主模块添加依赖项?
例子:
我的 AAR 库 gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.android.support:design:22.2.1')
compile('com.android.support:appcompat-v7:22.2.1')
compile('com.android.support:cardview-v7:22.2.1')
compile('com.android.support:recyclerview-v7:22.2.1')
compile('de.greenrobot:eventbus:2.4.0')
}
我的应用分级:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.firetrap.blaap"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ('my_package_name:channels.base@aar')
}
为什么我不能使用我的 AAR 中的 com.android.support:cardview-v7:22.2.1?
【问题讨论】:
-
您是使用 libs 文件夹中的 aar 还是使用 maven 存储库?
-
我都试过了,我有一个个人 maven repo 并上传了 aar 并使用它,结果是一样的
-
aar 文件不包含依赖项,如果使用本地 aar 文件,则必须在主模块中添加所有依赖项。对于 maven repo,检查 pom 文件
标签: android gradle android-gradle-plugin aar