穿App和自定义生成类型与applicationIdSuffix自定义、类型、App、applicationIdSuffix

2023-09-04 23:33:10 作者:封笔

我有一个应用程序,我想补充的Andr​​oid Wear应用程序扩展。主要的应用程序有三种内建类型(调试,测试和发布)。 Beta版有一个 applicationIdSuffix 这让我安装播放存储的版本和并行开发版本在同一设备上。这一切都运行良好,直到我添加了耐磨的应用程序。

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.

主要app`s 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')
}

耐磨应用程序具有相同的applicationIdSuffix值相同的生成类型。然而,当我建立测试应用程序(通过调用摇篮assembleBeta )的构建过程中建立:戴:assembleRelease 而不是:戴: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.

我怎么能告诉构建过程构建正确的生成类型与构建类型包装的主要应用程序时,测试版

推荐答案

发布之后由斯科特·巴塔链接(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 :

在磨损应用程序的build.gradle,添加 publishNonDefault真正(发布所有变型):

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')
 
精彩推荐