Proyecto Android wear con 3 sabores, 3 buildTypes y 2 applicationIdSuffixes


Cuando compilo mi proyecto después de intentar combinar sabores y tipos de compilación de wearApp con applicationIdSuffixes, recibo el siguiente mensaje de error:

Error:Execution failed for task ':app:handleFirstCustomerTestMicroApk'.
> The main and the micro apps do not have the same package name.

Desde mi app/build.gradle:

buildTypes {
    debug {
        applicationIdSuffix '.debug'
        debuggable true
        embedMicroApp = true
    }
    customerTest {
        applicationIdSuffix '.customertest'
        debuggable true
        embedMicroApp = true
    }
    release {
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        minifyEnabled true
        embedMicroApp = true
    }
}

productFlavors {
    first {
        applicationId 'com.my.app.first'
    }
    second {
        applicationId 'com.my.app.second'
    }
    third {
        applicationId 'com.my.app.third'
    }
}

dependencies {
    firstWearApp project(path: ':wear', configuration: 'firstDebug')
    firstWearApp project(path: ':wear', configuration: 'firstCustomerTest')
    firstWearApp project(path: ':wear', configuration: 'firstRelease')

    secondWearApp project(path: ':wear', configuration: 'secondDebug')
    secondWearApp project(path: ':wear', configuration: 'secondCustomerTest')
    secondWearApp project(path: ':wear', configuration: 'secondRelease')

    thirdWearApp project(path: ':wear', configuration: 'thirdDebug')
    thirdWearApp project(path: ':wear', configuration: 'thirdCustomerTest')
    thirdWearApp project(path: ':wear', configuration: 'thirdRelease')
}

De mi desgaste/construcción.gradle:

buildTypes {
    debug {
        applicationIdSuffix '.debug'
        minifyEnabled false
    }
    customerTest {
        applicationIdSuffix '.customertest'
        minifyEnabled false
    }
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
    first {
        applicationId 'com.my.app.first'
    }
    second {
        applicationId 'com.my.app.second'
    }
    third {
        applicationId 'com.my.app.third'
    }
}

android {
    publishNonDefault true
}

Sé por estos que <buildType>WearApp es posible, pero lo que realmente necesito es <flavor><BuildType>WearApp (que no parece ser posible en este momento):

Mantener todas las 9 dependencias de wearApp anteriores funciona si elimino los applicationIdSuffixes, pero aún así crea un apk de wear por tipo de compilación sin importar qué tipo de compilación elija en Android Studio, y realmente necesito los applicationIdSuffixes.

Alguien tiene una solución para esto? A partir de hoy estoy agregando y eliminando wearApp dependencias manualmente cada vez que necesito cambiar mi buildType y / o sabor, y no es exactamente una solución con la que me sienta cómodo a largo plazo.

EDITAR: No me di cuenta de esto al principio, pero por alguna razón variantes firstDebug, secondDebug y thirdDebug construye muy bien con todas las 9 dependencias de wearApp en build.gradle. Sin embargo, el mensaje de error sigue siendo el mismo para firstCustomerTest, Firststrelease, secondCustomerTest, secondRelease, thirdCustomerTest y thirdRelease. Todas las variantes compilar los 9 wearApps cada vez, sería bueno reducir esto a 1.

Author: Community, 2015-11-10

1 answers

De acuerdo con Este Post

Prueba esto

configurations {
    firstDebugWearApp
    firstCustomerTestWearApp
    firstReleaseWearApp
    secondDebugWearApp
 ...//  And all the others
}
  dependencies {
        firstDebugWearApp project(path: ':wear', configuration: 'firstDebug')
        firstCustomerTestWearApp project(path: ':wear', configuration: 'firstCustomerTest')
        firstReleaseWearApp project(path: ':wear', configuration: 'firstRelease')

        secondDebugWearApp project(path: ':wear', configuration: 'secondDebug')
        secondCustomerTestWearApp project(path: ':wear', configuration: 'secondCustomerTest')
        secondReleaseWearApp project(path: ':wear', configuration: 'secondRelease')

        thirdDebugWearApp project(path: ':wear', configuration: 'thirdDebug')
        thirdCustomerTestWearApp project(path: ':wear', configuration: 'thirdCustomerTest')
        thirdReleaseWearApp project(path: ':wear', configuration: 'thirdRelease')
    }
 8
Author: lowwor,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-04 08:24:17