Android wear项目具有3种风格、3种构建类型和2个应用程序补丁
在尝试将wearApp风格和构建类型与ApplicationIDSuffix组合后构建项目时,我收到以下错误消息:Android wear项目具有3种风格、3种构建类型和2个应用程序补丁,android,build.gradle,wear-os,android-productflavors,android-build-type,Android,Build.gradle,Wear Os,Android Productflavors,Android Build Type,在尝试将wearApp风格和构建类型与ApplicationIDSuffix组合后构建项目时,我收到以下错误消息: Error:Execution failed for task ':app:handleFirstCustomerTestMicroApk'. > The main and the micro apps do not have the same package name. 从我的应用程序/build.gradle: buildTypes { debug {
Error:Execution failed for task ':app:handleFirstCustomerTestMicroApk'.
> The main and the micro apps do not have the same package name.
从我的应用程序/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')
}
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
}
从my wear/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')
}
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
}
从这些信息中我知道,WearApp
是可能的,但我真正需要的是WearApp
(目前似乎不可能):
configurations {
firstDebugWearApp
firstCustomerTestWearApp
firstReleaseWearApp
secondDebugWearApp
...// And all the others
}
dependencies {
firstDebugWearApp project(path: ':wear', configuration: 'firstDebug')
firstCustomerTestWearApp project(path: ':wear', configuration: 'firstCustomerTest')
firstReleaseWearApp project(path: ':wear', configuration: 'firstRelease')
secondDebugWearApp project(path: ':wear', configuration: 'secondDebug')
secondCustomerTestWearApp project(path: ':wear', configuration: 'secondCustomerTest')
secondReleaseWearApp project(path: ':wear', configuration: 'secondRelease')
thirdDebugWearApp project(path: ':wear', configuration: 'thirdDebug')
thirdCustomerTestWearApp project(path: ':wear', configuration: 'thirdCustomerTest')
thirdReleaseWearApp project(path: ':wear', configuration: 'thirdRelease')
}
谢谢,“配置”是丢失的链接!它仍然会在每个构建上构建所有这些,但重要的是它正在工作。与您的问题无关:在buildTypes customerTest中定义“initwith debug”,这样您的自定义构建类型将自动使用“debug”中的所有设置。现在,您只需要定义“applicationIdSuffix”:与“debug”相比,唯一不同的是请参阅dev.android.com以获取参考:。。。我知道这在你的情况下不是非常有用,但我还是想指出可能性。