我有一个应用,我想在其中添加 Android Wear 应用扩展.主应用程序具有三种构建类型(调试、测试和发布).Beta 版本有一个 applicationIdSuffix
,它允许我在同一台设备上并行安装 play-store 版本和当前开发版本.这一切都很好,直到我添加了磨损应用程序.
I have an app where I'd like to add an Android Wear app extension. The main app has three build types (debug, beta and release). Beta builds have an applicationIdSuffix
which allows me to install the play-store version and the current development version in parallel on the same device. This all worked fine until I added the wear app.
主应用的 build.gradle
如下所示:
The main app`s build.gradle
looks like this:
apply plugin: 'com.android.application'
android {
...
defaultConfig {
...
applicationId "com.example.mainApp"
...
}
buildTypes {
debug {
applicationIdSuffix '.debug'
}
beta {
applicationIdSuffix '.beta'
}
release {
}
}
}
dependencies {
...
wearApp project(':wear')
}
Wear-App 具有相同的构建类型和相同的 applicationIdSuffix 值.但是,当我构建 beta 应用程序(通过调用 gradle assembleBeta
)时,构建过程会构建 :wear:assembleRelease
而不是 :wear:assembleBeta
这就是为什么我在构建期间收到以下错误消息:
The Wear-App has the same build types with the same applicationIdSuffix values. However, when I build the beta app (by calling gradle assembleBeta
) the build process builds :wear:assembleRelease
instead of :wear:assembleBeta
which is why I get the following error message during build:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:handleBetaMicroApk'.
> The main and the micro apps do not have the same package name.
在使用构建类型beta
打包主应用程序时,如何告诉构建过程构建正确的构建类型?
How can I tell the build process to build the correct build type when packaging the main app with build type beta
?
按照 Scott Barta 发布的链接 (http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication) 我想出了这个:
Following the link posted by Scott Barta (http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication) I came up with this :
在wear app的build.gradle中,添加publishNonDefault true
(发布所有变种):
In the build.gradle of the wear app, add publishNonDefault true
(to publish all variants):
android {
publishNonDefault true
}
在主应用的build.gradle中,
替换
In the build.gradle of the main app,
Replace
wearApp project(':wear')
由
debugWearApp project(path:':wear', configuration: 'debug')
releaseWearApp project(path:':wear', configuration: 'release')
这篇关于Wear App 和带有 applicationIdSuffix 的自定义构建类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!