Android wear application packaging fails with flavours

前端 未结 4 883
借酒劲吻你
借酒劲吻你 2020-12-13 15:19

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 o

4条回答
  •  隐瞒了意图╮
    2020-12-13 15:30

    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:

    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')
    }
    

    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
        }
     }
    }
    

提交回复
热议问题