Android Wear 应用程序打包失败

时间:2023-02-12
本文介绍了Android Wear 应用程序打包失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含穿戴应用程序的应用程序.在使用真实设备进行调试测试时一切正常.我还可以创建将磨损 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模板网!

上一篇:RxJavaPlugins 错误找不到类“com.google.devtools.build. 下一篇:如何在 build.gradle 中获取资源值?

相关文章

最新文章