Android Wear Projekt mit 3 Geschmacksrichtungen, 3 BuildTypes und 2 applicationIdSuffixes
Wenn ich mein Projekt erstelle, nachdem ich versucht habe, wearApp-Varianten und buildTypes mit applicationIdSuffixes zu kombinieren, wird die folgende Fehlermeldung angezeigt:
Error:Execution failed for task ':app:handleFirstCustomerTestMicroApk'.
> The main and the micro apps do not have the same package name.
Von meiner 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')
}
Von meinem 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
}
Ich weiß aus diesen, dass<buildType>WearApp
ist möglich, aber was ich wirklich brauche, ist<flavor><BuildType>WearApp
(was momentan nicht möglich zu sein scheint):
Das Beibehalten der oben genannten 9 wearApp-Abhängigkeiten funktioniert, wenn ich die applicationIdSuffixes entferne, aber dann wird immer noch eine wear-apk pro buildType erstellt, egal welchen buildType ich in Android Studio auswähle - und ich brauche die applicationIdSuffixes wirklich.
Hat jemand eine Problemumgehung dafür? Ab heute füge ich wearApp-Abhängigkeiten jedes Mal manuell hinzu und entferne sie, wenn ich meinen Build-Typ und / oder meine Version ändern muss. Dies ist auf lange Sicht keine gute Lösung.
EDIT: Das habe ich zunächst nicht bemerkt, aber aus irgendeinem Grund funktionieren die Varianten firstDebug, secondDebug und thirdDebug mit allen 9 wearApp-Abhängigkeiten in build.gradle einwandfrei. Die Fehlermeldung bleibt jedoch für firstCustomerTest, firstRelease, secondCustomerTest, secondRelease, thirdCustomerTest und thirdRelease gleich. Alle Varianten kompilieren die 9 wearApps jedes Mal, es wäre ordentlich diese auf 1 zu reduzieren.