Android app packaging doesn't suit tastes

I have an app that includes a wearing app. Everything works fine when checking debugging using a real device. I can create an apk album that packs apk from it. But only if there is only one taste in my application.

I want to support two versions of an application with different applications, but despite the fact that this compilation is error-free, in this case two release apks (one of each taste) do not combine the corresponding nose apks.

This is an important part of the build.gradle mobile app:

productFlavors { Trial { applicationId "com.example.myapp.trial" versionName "3.0.1" versionCode 301 } Full { applicationId "com.example.myapp" versionName "3.0.1" versionCode 301 } } } dependencies { compile 'com.google.android.gms:play-services:6.1.+@aar' wearApp project(':myWearApp') } 

And here is this application for creating boot material for correspondence:

 productFlavors { Trial { applicationId "com.example.myapp.trial" versionName "3.0.1" versionCode 301 } Full { applicationId "com.example.myapp" versionName "3.0.1" versionCode 301 } } } dependencies { compile 'com.google.android.support:wearable:1.0.0' compile 'com.google.android.gms:play-services-wearable:6.1.71' } 

Any help would be appreciated. Thank you

+18
android android-wear android-gradle
Dec 09 '14 at 19:42
source share
4 answers

Thanks to the hint, Scott gave me this complete solution:

1.) Flavors must be lowercase

2.) dependency configurations should include flavor Release

3.) In the app Wear app buil gradle, under android {}, we must enable publishNonDefault true

So, for the build.gradle mobile app:

 android { ...... productFlavors { trial { applicationId "com.sample.myapp.trial" versionName "3.0.1" versionCode 301 } full { applicationId "com.sample.myapp" versionName "3.0.1" versionCode 301 } } } dependencies { trialWearApp project(path: ':myWearApp', configuration: 'trialRelease') fullWearApp project(path: ':myWearApp', configuration: 'fullRelease') } 

And to wear the app build.gradle:

 android { publishNonDefault true ...... productFlavors { trial { applicationId "com.sample.myapp.trial" versionName "3.0.1" versionCode 301 } full { applicationId "com.sample.myapp" versionName "3.0.1" versionCode 301 } } } 
+31
Dec 10 '14 at 16:12
source share

The taste of the parent application does not automatically apply to the Wear project. You must display it explicitly.

Instead of this:

 dependencies { wearApp project(':myWearApp') } 

Do it:

In the Wear app:

 android { publishNonDefault true } 

In your parent application:

 dependencies { TrialWearApp project(path: ':myWearApp', configuration: 'Trial') FullWearApp project(path: ':myWearApp', configuration: 'Full') } 
+6
Dec 09 '14 at 19:52
source share

I see that you have found a solution to your problem, but here is my version that combines assembly configurations with the flavors and suffixes of applications in case you need it in the future. It may also be relevant information for those who fall into this post.

Application / build.gradle:

 android { compileSdkVersion 23 buildToolsVersion '23.0.3' signingConfigs { debug { ... } release { ... } } defaultConfig { applicationId "com.sample.myapp" minSdkVersion 14 targetSdkVersion 23 versionName "3.0.1" versionCode 301 } buildTypes { debug { applicationIdSuffix ".debug" embedMicroApp = true minifyEnabled false debuggable true } release { embedMicroApp = true minifyEnabled true zipAlignEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } productFlavors { trial { applicationIdSuffix ".trial" } full { applicationIdSuffix ".pro" } } } configurations { trialDebugWearApp fullDebugWearApp trialReleaseWearApp fullReleaseWearApp } dependencies { ... trialDebugWearApp project(path: ':myWearApp', configuration: 'trialDebug') fullDebugWearApp project(path: ':myWearApp', configuration: 'fullDebug') trialReleaseWearApp project(path: ':myWearApp', configuration: 'trialRelease') fullReleaseWearApp project(path: ':myWearApp', configuration: 'fullRelease') } 

wear / build.gradle:

 android { compileSdkVersion 23 buildToolsVersion '23.0.3' publishNonDefault true signingConfigs { debug { ... } release { ... } } defaultConfig { applicationId "com.sample.myapp" minSdkVersion 20 targetSdkVersion 23 versionName "3.0.1" versionCode 301 } buildTypes { debug { applicationIdSuffix ".debug" minifyEnabled false debuggable true } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } productFlavors { trial { applicationIdSuffix ".trial" } full { applicationIdSuffix ".pro" } } dependencies { ... } } 
+1
04 Feb '16 at 9:39
source share

I will add a bit more @tormod answer as it omitted some important points to enable publishNonDefault true




Here are some examples of gradle files for packing a wear module with aromas and types of designs.

Mobile build.gradle

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.example.app" minSdkVersion 15 targetSdkVersion 23 versionCode 85 versionName "2.5.2" } buildTypes { debug { applicationIdSuffix ".debug" embedMicroApp = true minifyEnabled false } release { embedMicroApp = true shrinkResources true minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' zipAlignEnabled true } } productFlavors { free{ applicationId "com.example.app" } pro{ applicationId "com.example.app.pro" } } } configurations { freeDebugWearApp proDebugWearApp freeReleaseWearApp proReleaseWearApp } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' freeDebugWearApp project(path: ':wear', configuration: 'freeDebug') proDebugWearApp project(path: ':wear', configuration: 'proDebug') freeReleaseWearApp project(path: ':wear', configuration: 'freeRelease') proReleaseWearApp project(path: ':wear', configuration: 'proRelease') } 



Wear of the build.gradle module

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" publishNonDefault true defaultConfig { applicationId "com.example.app" minSdkVersion 20 targetSdkVersion 23 versionCode 85 versionName "2.5.2" } buildTypes { debug { applicationIdSuffix ".debug" minifyEnabled false } release { shrinkResources true minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' zipAlignEnabled true } } productFlavors { free { applicationId "com.example.app" } pro { applicationId "com.example.app.pro" } } } dependencies { ... } 
0
May 26 '16 at 13:43
source share



All Articles