1

When I try to add a flavor to my project, Gradle simply don't want to sync and even if I sync it I can't see the flavor in Build Variats. What can cause this problem? The project has a few modules, I need to add flavors to the app. My file:

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

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.24.4'
    }
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


def keystorePropertiesFile = "${rootDir}${File.separator}keystore.properties" as File

keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {

    dexOptions {
           javaMaxHeapSize "4g"
    }

    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId ""
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 9999
        versionName "17.2 (9999)"
    }

    productFlavors {
        testFlavor {
            applicationId "com.volodymyr.mobiletest"
        }
    }

    def keystoreFilePath = "${System.properties['user.home']}${File.separator}${keystoreProperties['storeFile']}"
    signingConfigs {
        config {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreFilePath)
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {

        }
        debug {

        }
    }
    splits {
        abi {
            enable true
            reset()
            include 'armeabi-v7a', 'arm64-v8a'//, 'x86', 'x86_64'
            universalApk true
        }
    }

    lintOptions {
        lintConfig file("lint.xml")

        check "WrongConstant"
        abortOnError true
    }
}

tasks.whenTaskAdded { task ->
    if(task.name.equals("assembleDebug")){
        task.dependsOn(lint)
    }
}
dependencies {
}

I deleted some info from here, like dependencies, id and so on just to show a structure.

VolodymyrH
  • 1,927
  • 2
  • 18
  • 47

2 Answers2

0

Error:(15, 0) ProductFlavor names cannot start with 'test'

You should use another flavor name

Linh
  • 57,942
  • 23
  • 262
  • 279
  • ^^ cannot start with 'test' not mean equal `test`. your flavor name now is `testFlavor` (it start with test). you should change it to demoFlavor or abcFlavor, ... not test... – Linh Nov 03 '17 at 09:33
  • I still can't see "Sourse set" if I add some resource. Gradle still don't want to sync and I don't see flavors at Build Types – VolodymyrH Nov 03 '17 at 09:39
  • what is your android studio version? does gradle display any error? try restart android studio. – Linh Nov 03 '17 at 09:41
  • 3.0. No errors, may it be caused by gradle version? – VolodymyrH Nov 03 '17 at 09:42
  • which is your build gradle? – Linh Nov 03 '17 at 09:44
  • 2.3.3 because of project. I also tried 3.0.0 -- the same. But if I create small test app I can do it without problems. In build types I see just release and debug, while I expect flavors – VolodymyrH Nov 03 '17 at 09:47
  • im using android studio 3 with gradle:3.0.0 and flavor work ok :D. note that you need to add flavorDimensions when use use AS 3.0 https://stackoverflow.com/a/44105198/5381331 – Linh Nov 03 '17 at 09:47
  • It works well for me too, but exactly at that project it doesn't work – VolodymyrH Nov 03 '17 at 09:51
  • I have no more idea because your AS don't show any error log. I suggest that you should try remove each property in your gradle and sync project step by step and figure out which thing make your flavor not work – Linh Nov 03 '17 at 09:53
0

The problem was in that that this gradle file is using only for CI. To change gradle config I needed to improve build file at settings.gradle.

VolodymyrH
  • 1,927
  • 2
  • 18
  • 47