問題描述
我有一個包含穿戴應(yīng)用程序的應(yīng)用程序.在使用真實設(shè)備進行調(diào)試測試時一切正常.我還可以創(chuàng)建將磨損 apk 打包在其中的發(fā)布 apk.但前提是我的應(yīng)用程序只有一種風(fēng)格.
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.
我想維護具有不同 applicationId 的應(yīng)用程序的兩個版本,但是盡管編譯沒有錯誤,但在這種情況下,兩個發(fā)布 apk(每種風(fēng)格一個)不包含相應(yīng)的磨損 apk.
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.
這是移動應(yīng)用 build.gradle 的相關(guān)部分:
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')
}
這是對應(yīng)的wear app build.gradle:
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'
}
歡迎任何幫助.謝謝.
推薦答案
感謝 Scott 給我的線索,這是完整的解決方案:
Thanks to the clue Scott gave me this is the full solution:
1.) 味道必須小寫
2.) 依賴配置必須包含flavorRelease
2.) dependency configurations must include flavorRelease
3.) 在 Wear app build gradle 中,在 android{} 下,我們必須包含 publishNonDefault true
3.) In Wear app buil gradle, under android{}, we must include publishNonDefault true
所以對于移動應(yīng)用 build.gradle:
So for mobile app build.gradle:
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')
}
對于穿戴應(yīng)用程序 build.gradle:
And for wear 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
}
}
}
這篇關(guān)于Android Wear 應(yīng)用程序打包失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!