具有3种口味,3种buildTypes和2种applicationIdSuffixes的Android Wear项目 [英] Android wear project with 3 flavors, 3 buildTypes and 2 applicationIdSuffixes

查看:242
本文介绍了具有3种口味,3种buildTypes和2种applicationIdSuffixes的Android Wear项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将wearApp的味道和buildTypes与applicationIdSuffixes结合起来后构建项目时,出现以下错误消息:

When I build my project after trying to combine wearApp flavors and buildTypes with applicationIdSuffixes, i get the following error message:

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

来自我的app / build.gradle:

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

来自我的wear / build.gradle:

From my wear/build.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
}

我从中知道< buildType> WearApp 是可能的,但我真正需要的是< flavor>< BuildType> WearApp (目前似乎不可能):

I know from these that <buildType>WearApp is possible, but what I really need is <flavor><BuildType>WearApp (which don't seem to be possible right now):

  • Android wear application packaging fails with flavours
  • Wear App and with custom build type with applicationIdSuffix
  • https://code.google.com/p/android/issues/detail?id=74658

如果我删除了applicationIdSuffixes,上述9种wearApp依赖项都可以正常工作,但是无论我在Android Studio中选择哪种buildType,它仍会为每个buildType构建一个Wear apk-我确实需要applicationIdSuffixes。

Keeping all the above 9 wearApp dependencies sort of works if I remove the applicationIdSuffixes, but then it still builds one wear apk per buildType no matter what buildType I choose in Android Studio - and I really need the applicationIdSuffixes.

有人对此有解决方法吗?从今天开始,每次需要更改buildType和/或风味时,我都会手动添加和删除wearApp依赖项,从长远来看,这并不是我完全满意的解决方案。

Anyone have a workaround for this? As of today I'm adding and removing wearApp dependencies manually every time I need to change my buildType and / or flavor, and it's not exactly a solution I'm comfortable with in the long run.

编辑:起初我没有注意到这一点,但是出于某种原因,在build.gradle中使用所有9个wearApp依赖项构建了firstDebug,secondDebug和thirdDebug变体就很好。错误消息对于firstCustomerTest,firstRelease,secondCustomerTest,secondRelease,thirdCustomerTest和thirdRelease仍然相同。所有变体每次都会编译9个wearApp,将其精简地减少到1个。

I didn't notice this at first, but for some reason variants firstDebug, secondDebug and thirdDebug builds just fine with all 9 wearApp dependencies in build.gradle. The error message remains the same for firstCustomerTest, firstRelease, secondCustomerTest, secondRelease, thirdCustomerTest and thirdRelease though. All variants compile the 9 wearApps every time, would be neat to reduce this to 1.

推荐答案

根据此帖子

尝试使用

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

这篇关于具有3种口味,3种buildTypes和2种applicationIdSuffixes的Android Wear项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆