I have an application that includes a wear app. All works fine on debug tested with a real device. I can alse create the release apk that packs the wear apk inside it. But only if there is only one flavour on my application.
I want to maintain two versions of the application with different applicationId, but although this compile without errors, in this case the two release apks (one of each flavour) don't cointain the corresponding wear apks.
This is the relevant part of the mobile app build.gradle:
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 this is the correspondig wear app build.gradle:
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 will be welcomed. Thanks.
I'll add a bit more to @tormod's answer as he omited some crucial points as to include the
publishNonDefault true
Here are some example Gradle files for packaging a wear module with flavours and buildtypes.
Module mobile
build.gradle
Module Wear
build.gradle
The flavor of the parent app isn't propagated automatically to the Wear project. You have to map it explicitly.
Instead of this:
Do this:
In your Wear app:
In your parent app:
Thanks to the clue Scott gave me this is the full solution:
1.) Flavors must be lowercase
2.) dependency configurations must include flavorRelease
3.) In Wear app buil gradle, under android{}, we must include publishNonDefault true
So for mobile app build.gradle:
And for wear app build.gradle:
I see that you found a solution to your problem, but here is my version that combines build configs with flavors and application suffixes in case you might need that in the future. Could also be relevant information for those who end up googling their way into this post.
app/build.gradle:
wear/build.gradle: