android 使用 gradle buildTypes 的不同 Apk

Different Apks for android using gradle buildTypes

我正在尝试在同一台设备上同时安装调试版和发布版,因此尝试将 applicationIdSuffix 添加到 gradle 文件的 buildTypes 块中,如文档中所述。没有提到创建任何包,而是说找不到包错误。请帮忙。

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

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

你的google配置文件(我认为是google-services.json文件)不包含com.edu.gcfapp.debug

的任何配置信息

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