我想创建一个Android自我一致的库,它具有内部外部依赖(如Retrofit)。我想在主项目中使用它,而不必重新导入所有库依赖项。可能吗?
这是我的LIBRARY build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "my.lib"
minSdkVersion 8
targetSdkVersion 21
versionCode 4
versionName "0.4.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.squareup.retrofit:retrofit:1.8.0'
}
这是我的APP build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "my.app"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// APP DEPENDENCIES
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
// LIB DEPENDENCIES
compile 'my.lib:example:0.1.0'
compile 'com.squareup.retrofit:retrofit:1.8.0' //<--- I don't want to re-import this dependency
}