Android构建变体无法使用不同的样式

时间:2018-09-18 11:40:59

标签: android gradle android-gradle android-build-flavors

我的应用程序中大约有20种口味。过去从1年以来一直运行良好,但是在更新到新的gradle版本4.4之后,它开始出现一个问题,找不到与包名称匹配的客户端

注意:现在,只有默认风味是工作文件。

请建议我解决此问题,

我已经解决了该问题,现在的错误是

Error:cannot access Hide
Error:Execution failed for task ':app:compileKissgc_customerDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.


    android {
        compileSdkVersion 26
        buildToolsVersion '26.0.2'
        defaultConfig {
            applicationId 'com.mobile.test'
            minSdkVersion 15
            targetSdkVersion 26

            multiDexEnabled true
            versionCode 46
            versionName "1"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                // minifyEnabled true
                false

    //            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
    //                    'proguard-rules.pro'
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        lintOptions {
            checkReleaseBuilds false
        }
        productFlavors {
            test{
                minSdkVersion 19
                applicationId 'com.mobile.test'
                targetSdkVersion 27
                versionCode 46
                versionName '1.0'
                flavorDimensions "default"
    //            deploy = "release|staging"
            }
            test1{
                minSdkVersion 19
                applicationId 'com.mobile.test1'
                targetSdkVersion 27
                versionCode 7777810
                versionName '1.0'
            }
}

  compile ("android.arch.persistence.room:runtime:1.0.0") {
        exclude group: 'com.android.support'
    }
    compile 'com.google.firebase:firebase-crash:12.0.1'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile('com.stripe:stripe-android:1.0.4@aar') {
        transitive = true;
    }

    compile 'com.android.support:appcompat-v7:26.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }
   // compile 'com.google.firebase:firebase-core:12.0.1'
//    compile 'com.google.android.gms:play-services:16.0.0'
    compile 'com.github.drawers:SpinnerDatePicker:1.0.6'
    compile 'info.hoang8f:android-segmented:1.0.6'
    implementation 'com.google.android.gms:play-services-wallet:16.0.0'

谢谢 阿米特·夏尔马(Amit Sharma)

2 个答案:

答案 0 :(得分:1)

在新的gradle版本中,必须在定义productflavors之前先定义flavorDimensions。如果您没有任何要提及的尺寸。然后默认情况下,您必须定义flavourDimensions“默认”

 flavorDimensions "default"
    productFlavors {
        test {
            applicationId "com.example.test"
        }

        tester {
            applicationId "com.example.tester"
        }
}

答案 1 :(得分:0)

尺寸应在上述范围内定义,而不是在每种口味下定义

每种口味都应参考现有的尺寸

flavorDimensions "default"
productFlavors {
            test{
                dimension "default"
                minSdkVersion 19
                applicationId 'com.mobile.test'
                targetSdkVersion 27
                versionCode 46
                versionName '1.0'
    //            deploy = "release|staging"
            }
            test1{
                dimension "default"
                minSdkVersion 19
                applicationId 'com.mobile.test1'
                targetSdkVersion 27
                versionCode 7777810
                versionName '1.0'
            }
}