問題描述
我有一個(gè)應(yīng)用,我想在其中添加 Android Wear 應(yīng)用擴(kuò)展.主應(yīng)用程序具有三種構(gòu)建類型(調(diào)試、測試和發(fā)布).Beta 版本有一個(gè) applicationIdSuffix
,它允許我在同一臺(tái)設(shè)備上并行安裝 play-store 版本和當(dāng)前開發(fā)版本.這一切都很好,直到我添加了磨損應(yīng)用程序.
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.
主應(yīng)用的 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 具有相同的構(gòu)建類型和相同的 applicationIdSuffix 值.但是,當(dāng)我構(gòu)建 beta 應(yīng)用程序(通過調(diào)用 gradle assembleBeta
)時(shí),構(gòu)建過程會(huì)構(gòu)建 :wear:assembleRelease
而不是 :wear:assembleBeta
這就是為什么我在構(gòu)建期間收到以下錯(cuò)誤消息:
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.
在使用構(gòu)建類型beta
打包主應(yīng)用程序時(shí),如何告訴構(gòu)建過程構(gòu)建正確的構(gòu)建類型?
How can I tell the build process to build the correct build type when packaging the main app with build type beta
?
推薦答案
按照 Scott Barta 發(fā)布的鏈接 (http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication) 我想出了這個(gè):
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
(發(fā)布所有變種):
In the build.gradle of the wear app, add publishNonDefault true
(to publish all variants):
android {
publishNonDefault true
}
在主應(yīng)用的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')
這篇關(guān)于Wear App 和帶有 applicationIdSuffix 的自定義構(gòu)建類型的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!