Projeto de desgaste do Android com 3 sabores, 3 buildTypes e 2 applicationIdSuffixes
Quando crio meu projeto depois de tentar combinar os sabores wearApp e buildTypes com applicationIdSuffixes, recebo a seguinte mensagem de erro:
Error:Execution failed for task ':app:handleFirstCustomerTestMicroApk'.
> The main and the micro apps do not have the same package name.
No meu app / build.gradle:
buildTypes {
debug {
applicationIdSuffix '.debug'
debuggable true
embedMicroApp = true
}
customerTest {
applicationIdSuffix '.customertest'
debuggable true
embedMicroApp = true
}
release {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
minifyEnabled true
embedMicroApp = true
}
}
productFlavors {
first {
applicationId 'com.my.app.first'
}
second {
applicationId 'com.my.app.second'
}
third {
applicationId 'com.my.app.third'
}
}
dependencies {
firstWearApp project(path: ':wear', configuration: 'firstDebug')
firstWearApp project(path: ':wear', configuration: 'firstCustomerTest')
firstWearApp project(path: ':wear', configuration: 'firstRelease')
secondWearApp project(path: ':wear', configuration: 'secondDebug')
secondWearApp project(path: ':wear', configuration: 'secondCustomerTest')
secondWearApp project(path: ':wear', configuration: 'secondRelease')
thirdWearApp project(path: ':wear', configuration: 'thirdDebug')
thirdWearApp project(path: ':wear', configuration: 'thirdCustomerTest')
thirdWearApp project(path: ':wear', configuration: 'thirdRelease')
}
Do meu wear / build.gradle:
buildTypes {
debug {
applicationIdSuffix '.debug'
minifyEnabled false
}
customerTest {
applicationIdSuffix '.customertest'
minifyEnabled false
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
productFlavors {
first {
applicationId 'com.my.app.first'
}
second {
applicationId 'com.my.app.second'
}
third {
applicationId 'com.my.app.third'
}
}
android {
publishNonDefault true
}
Eu sei disso que<buildType>WearApp
é possível, mas o que eu realmente preciso é<flavor><BuildType>WearApp
(que parece não ser possível no momento):
Manter todas as 9 dependências wearApp acima funcionará se eu remover o applicationIdSuffixes, mas ele ainda criará um apk de desgaste por buildType, independentemente do buildType que eu escolher no Android Studio - e realmente preciso do applicationIdSuffixes.
Alguém tem uma solução alternativa para isso? Atualmente, estou adicionando e removendo dependências do wearApp manualmente toda vez que preciso alterar meu buildType e / ou sabor, e não é exatamente uma solução com a qual me sinto confortável a longo prazo.
EDIT: Eu não percebi isso no começo, mas por algumas razões, as variantes firstDebug, secondDebug e thirdDebug compilam perfeitamente com todas as 9 dependências wearApp no build.gradle. A mensagem de erro permanece a mesma para firstCustomerTest, firstRelease, secondCustomerTest, secondRelease, thirdCustomerTest e thirdRelease. Todas as variantes compilam os 9 wearApps toda vez, seria legal reduzir isso para 1.