업데이트 : 다른 해결책을 찾았습니다. 그것은 또 다른 대답입니다.
android gradle plugin의 'Flavor products'의 사용법으로 가능합니다. 제품 구현에 따라 라이브러리 구현을 분리 할 수 있습니다.
초기 요구 사항 'com.android.tools.build:gradle:1.0.0', 안드로이드 스튜디오 1.0.1.
나는 project at GitHub을 만들었으므로 배우고 실행하고 배우게됩니다.
앱과 라이브러리의 두 가지 맛을 만들어야합니다. 예를 들어, normal
및 simulator
응용 프로그램의 build.gradle
apply plugin: 'com.android.application'
android {
lintOptions {
abortOnError false
}
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.tivogi.gradle"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
normal {
}
simulator {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
normalCompile project(path: ':library', configuration: 'normalRelease')
simulatorCompile project(path: ':library', configuration: 'simulatorRelease')
}
도서관의 build.gradle
apply plugin: 'com.android.library'
android {
publishNonDefault true
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
normal {
}
simulator {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
라이브러리 :에 의해 맛과
응용 프로그램 :
당신이 applicaiton의 2 개 변종 구축 할 수 있습니다 : 정상 및 시뮬레이터를.
출처
2014-12-17 09:55:47
gio
고맙습니다. 그것은 일했다 :) –