gpt4 book ai didi

具有 3 个风格、3 个 buildTypes 和 2 个 applicationIdSuffixes 的 Android Wear 项目

转载 作者:IT老高 更新时间:2023-10-28 21:53:04 25 4
gpt4 key购买 nike

当我尝试将 wearApp 风格和 buildTypes 与 applicationIdSuffixes 结合后构建我的项目时,我收到以下错误消息:

Error:Execution failed for task ':app:handleFirstCustomerTestMicroApk'.
> The main and the micro apps do not have the same package name.

来 self 的 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')
}

来 self 的 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
}

我知道<buildType>WearApp是可能的,但我真正需要的是<flavor><BuildType>WearApp (现在似乎不可能):

如果我删除了 applicationIdSuffixes,则保留所有上述 9 个 wearApp 依赖项的工作,但是无论我在 Android Studio 中选择什么 buildType,它仍然会为每个 buildType 构建一个 wear apk - 我真的需要 applicationIdSuffixes。

有人有解决方法吗?到今天为止,每次我需要更改 buildType 和/或 flavor 时,我都会手动添加和删除 wearApp 依赖项,从长远来看,这并不是我喜欢的解决方案。

编辑:一开始我没有注意到这一点,但由于某种原因,变体 firstDebug、secondDebug 和 thirdDebug 与 build.gradle 中的所有 9 个 wearApp 依赖项一起构建得很好。但是,对于 firstCustomerTest、firstRelease、secondCustomerTest、secondRelease、thirdCustomerTest 和 thirdRelease,错误消息仍然相同。所有变体每次都编译 9 个 wearApp,将其减少到 1 个会很巧妙。

最佳答案

根据This Post

试试这个

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')
}

关于具有 3 个风格、3 个 buildTypes 和 2 个 applicationIdSuffixes 的 Android Wear 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33630929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com