[英]How to get current buildType in Android Gradle configuration
[英]Gradle: How to have a 'mock' buildType depend on a 'mock' buildType of another android library project?
我有兩個gradle模塊
:app
(Android應用程序) :data
(Android庫) :app
取決於:data
。 我創建了一個額外的buildType
兩個模塊叫做mock
。 當我在mock
buildType
構建:app
時,我希望:data
在mock
buildType
自動構建。 我該如何實現?
我在:app
的build.gradle
嘗試了以下build.gradle
:
mockCompile project(path: ':data', configuration: 'mock')
但是會引發此錯誤: Error: Configuration with name 'mock' not found.
:data
具有以下buildTypes
:
android {
buildTypes {
debug {
shrinkResources true
}
mock {
initWith(buildTypes.debug)
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
將以下行添加到數據模塊的build.gradle中
publishNonDefault true
默認情況下,Android只是發布您的庫的發行版,因此app模塊無法看到您的數據庫的模擬版。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.