找不到与Flavors对应的包名匹配的客户端。

3

我正在使用Flavor为同一应用程序生成多个版本,唯一变化的是风格,但我需要上传多个apk到Playstore,但在尝试构建项目时出现问题,标记为“找不到与包名匹配的客户端”的错误。

我的build.gradle文件如下:

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

“mx.com.locker.starwing.puntoarq”未找到。
1个回答

2
尝试使用applicationIdSuffix来更改每个产品口味的应用程序ID,例如:
android {
    ...
    defaultConfig {
        applicationId "mx.com.locker"
        ...
    }
    productFlavors {
        starwing {
            applicationIdSuffix ".starwing"
            versionCode 11
            versionName "1.11"
        }
        puntoarq {
            applicationIdSuffix ".puntoarq"
            versionCode 1
            versionName "1"
        }
    }
}

请确保您为每个风味的res文件夹放置在其相应目录中,如下所示:

# 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
                        \__ ...

如果您正在使用一些谷歌服务,那么源代码文件同样需要,当然还有 google-services.json 文件。

# 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

您可以从Android Studio中选择构建变体或运行./gradlew assembleStarwingRelease./gradlew assemblePuntoarqRelease来构建您的特定版本。

您可以在这里查看更多信息。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接