問題描述
我有一個包含穿戴應用程序的應用程序.在使用真實設備進行調試測試時一切正常.我還可以創建將磨損 apk 打包在其中的發布 apk.但前提是我的應用程序只有一種風格.
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 的應用程序的兩個版本,但是盡管編譯沒有錯誤,但在這種情況下,兩個發布 apk(每種風格一個)不包含相應的磨損 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.
這是移動應用 build.gradle 的相關部分:
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')
}
這是對應的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
所以對于移動應用 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')
}
對于穿戴應用程序 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
}
}
}
這篇關于Android Wear 應用程序打包失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!