我有一个应用,我想在其中添加 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模板网!
更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 IncompIncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 Incompatible
如何在 gradle 中获取当前风味How to get current flavor in gradle(如何在 gradle 中获取当前风味)
如何修复“意外元素<查询>在“清单How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修复“意外元素lt;查询gt;在“清单中找到错误
基于 Android Gradle 中多风味库的多风味应用Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多风味库的多风味应用)
Android 依赖在编译和运行时有不同的版本Android dependency has different version for the compile and runtime(Android 依赖在编译和运行时有不同的版本)
本地 aar 库的传递依赖Transitive dependencies for local aar library(本地 aar 库的传递依赖)