Search code examples
androidandroid-productflavors

No matching client found for package name with Flavors


Im using flavor for generated several versions of the same app, where the only thing that change is the style, but i need upload severals apk's to the playstore, but i have a problem when try build the project, mark "No matching client found for package name" error.

My build.gradle file is:

starwing {
        applicationId "mx.com.locker.starwing"
        versionCode 11
        versionName "1.11"
    }
    puntoarq {
        applicationId "mx.com.locker.starwing.puntoarq"
        versionCode 1
        versionName "1"
    }

The "mx.com.locker.starwing.puntoarq" is the one not found.


Solution

  • Try using applicationIdSuffix for changing the application id of each product flavor like:

    android {
        ...
        defaultConfig {
            applicationId "mx.com.locker"
            ...
        }
        productFlavors {
            starwing {
                applicationIdSuffix ".starwing"
                versionCode 11
                versionName "1.11"
            }
            puntoarq {
                applicationIdSuffix ".puntoarq"
                versionCode 1
                versionName "1"
            }
        }
    }
    

    And make sure you have your res folder for each flavor in their respective directory like this:

    # common/default resources here
    app/src/main/res/values
                           \___ /styles.xml
                           |___ /colors.xml
                            \__ ...
    
    # starwing resources here
    app/src/starwing/res/values
                           \___ /styles.xml
                           |___ /colors.xml
                            \__ ...
    
    # puntoarq resources here
    app/src/puntoarq/res/values
                           \___ /styles.xml
                           |___ /colors.xml
                            \__ ...
    

    The same for source code files and of course with the google-services.json if you are using some google service.

    # common/default resources here
    app/src/main/google-services.json
    
    # starwing resources here
    app/src/starwing/google-services.json
    
    # puntoarq resources here
    app/src/puntoarq/google-services.json
    

    You can build your specific flavor choosing the build variant from Android Studio or running ./gradlew assembleStarwingRelease or ./gradlew assemblePuntoarqRelease.

    You could take a look here for more information.