問題描述
我有一個應用,我想在其中添加 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 的自定義構建類型的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!