Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wear App and with custom build type with applicationIdSuffix

Tags:

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.

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') } 

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. 

How can I tell the build process to build the correct build type when packaging the main app with build type beta?

like image 997
Tom Avatar asked Aug 05 '14 14:08

Tom


2 Answers

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 :

In the build.gradle of the wear app, add publishNonDefault true (to publish all variants):

android {     publishNonDefault true } 

In the build.gradle of the main app,
Replace

wearApp project(':wear') 

By

debugWearApp project(path:':wear', configuration: 'debug') releaseWearApp project(path:':wear', configuration: 'release') 
like image 171
Cyril Leroux Avatar answered Sep 18 '22 19:09

Cyril Leroux


You can't do what you want; the build variant of a module isn't propagated to the builds of dependent modules on build. This is tracked in https://code.google.com/p/android/issues/detail?id=52962

There's a facility to make one module depend on a specific variant of another one, as documented in http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication, but I don't think this mechanism can be extended to do differential packaging of Wear apps.

like image 37
Scott Barta Avatar answered Sep 20 '22 19:09

Scott Barta