我有一个包含穿戴应用程序的应用程序.在使用真实设备进行调试测试时一切正常.我还可以创建将磨损 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模板网!
更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 IncompIncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 Incompatible
如何在 gradle 中获取当前风味How to get current flavor in gradle(如何在 gradle 中获取当前风味)
如何修复“意外元素<查询>在“清单How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修复“意外元素lt;查询gt;在“清单中找到错误
基于 Android Gradle 中多风味库的多风味应用Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多风味库的多风味应用)
Android 依赖在编译和运行时有不同的版本Android dependency has different version for the compile and runtime(Android 依赖在编译和运行时有不同的版本)
本地 aar 库的传递依赖Transitive dependencies for local aar library(本地 aar 库的传递依赖)