Android wear application packaging fails with flavours

前端 未结 4 876
借酒劲吻你
借酒劲吻你 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:39

    I see that you found a solution to your problem, but here is my version that combines build configs with flavors and application suffixes in case you might need that in the future. Could also be relevant information for those who end up googling their way into this post.

    app/build.gradle:

    android {
        compileSdkVersion 23
        buildToolsVersion '23.0.3'
    
        signingConfigs {
            debug { ... }
            release { ... }
        }
    
        defaultConfig {
            applicationId "com.sample.myapp"
            minSdkVersion 14
            targetSdkVersion 23
            versionName "3.0.1"
            versionCode 301
        }
    
        buildTypes {
            debug {
                applicationIdSuffix ".debug"
                embedMicroApp = true
                minifyEnabled false
                debuggable true
            }
            release {
                embedMicroApp = true
                minifyEnabled true
                zipAlignEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
    
        productFlavors {
            trial {
                applicationIdSuffix ".trial"
            }
            full {
                applicationIdSuffix ".pro"
            }
        }
    }
    
    configurations {
        trialDebugWearApp
        fullDebugWearApp
        trialReleaseWearApp
        fullReleaseWearApp
    }
    
    dependencies {
        ...
    
        trialDebugWearApp project(path: ':myWearApp', configuration: 'trialDebug')
        fullDebugWearApp project(path: ':myWearApp', configuration: 'fullDebug')
        trialReleaseWearApp project(path: ':myWearApp', configuration: 'trialRelease')
        fullReleaseWearApp project(path: ':myWearApp', configuration: 'fullRelease')
    }
    

    wear/build.gradle:

    android {
        compileSdkVersion 23
        buildToolsVersion '23.0.3'
    
        publishNonDefault true
    
        signingConfigs {
            debug { ... }
            release { ... }
        }
    
        defaultConfig {
            applicationId "com.sample.myapp"
            minSdkVersion 20
            targetSdkVersion 23
            versionName "3.0.1"
            versionCode 301
        }
    
        buildTypes {
            debug {
                applicationIdSuffix ".debug"
                minifyEnabled false
                debuggable true
            }
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
    
        productFlavors {
            trial {
                applicationIdSuffix ".trial"
            }
            full {
                applicationIdSuffix ".pro"
            }
        }
    
        dependencies {
            ...
        }
    }
    

提交回复
热议问题