使用gradle buildTypes的Android的不同Apks

时间:2018-04-17 05:56:40

标签: android gradle android-gradle android-productflavors

我试图在同一台设备上安装调试版和发行版,因此尝试在docs中提到的gradle文件的buildTypes块中添加applicationIdSuffix。没有提到创建任何包,并且它说包找不到错误。请帮忙。

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

def versionMajor = 1
def versionMinor = 0
def versionPatch = 4
def versionBuild = 0

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.edu.gcfapp"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }
    buildTypes {

        debug {
            applicationIdSuffix ".debug"
        }

        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    flavorDimensions "default"

错误我得到的是这个......

Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDevDebugGoogleServices'.
> No matching client found for package name 'com.edu.gcfapp.debug'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s

1 个答案:

答案 0 :(得分:1)

看起来您正在使用Google服务,尽管您已从您的gradle中省略了它。

您的google配置文件(我认为是google-services.json文件)不包含com.edu.gcfapp.debug的任何配置信息

返回谷歌控制台并为您的发布和调试包名称创建一个文件,并将它们放在相关的构建文件夹中。