Search code examples
androidwear-osandroid-productflavors

wear apk is not deploying when there are product flavors


When I try to deploy with these productFlavors, wear debug apk won't built and it is not embedded into mobile release apk. But after I delete productFlavors from mobile and wear build.gradle file, it's working as it should.

 productFlavors {
        lite {
        }
        pro {
            applicationId 'example.app.id.pro'
            versionNameSuffix '.pro'
        }
    }

Solution

  • Try assigning applicationIdSuffix and versionNameSuffix values for each of your product flavors. See Configuration of Product Flavors for more information.

    And if you haven't done yet, add publishNonDefault truein your Wear module's build.gradle file.

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

    See this related SO post and Packaging and Distributing Wear Apps for additional insights.