【问题标题】:Generate APK's with different keystores使用不同的密钥库生成 APK
【发布时间】:2018-12-16 08:42:21
【问题描述】:

我创建了不同风格的项目。 每种风格都有自己的应用程序 ID、密钥库和密码。

在 gradle 文件中,我添加了 signingConfigs 部分来设置 keyAliaskeyPasswordstoreFilestorePassword

接下来,在buildTypesrelease 部分,我为每种风格设置了签名配置。

然后,我生成了所有口味。我得到了所有具有正确内容和包名称的apk.. 但是当我尝试上传到游戏商店时,我得到了一个错误:

Upload failed: You uploaded an APK that is not signed with the upload certificate. 
               You must use same certificate.
               The uploaded certificate has fingerprint "A" and the certificate
               used to sign the APK you uploaded have fingerprint "B".

现在,我知道它使用了不同的证书。我的问题是如何从 gradle 修复它? 那么APK的生成过程也会区分不同的证书,并为每个flavor使用正确的证书?

gradle 文件如下所示:

android{

    signingConfigs {
        flavorA {
            keyAlias flavorAKeystoreProperties['keyAlias']
            keyPassword flavorAKeystoreProperties['keyPassword']
            storeFile file(flavorAKeystoreProperties['storeFile'])
            storePassword flavorAKeystoreProperties['storePassword']
        }

        flavorB {
            keyAlias flavorBKeystoreProperties['keyAlias']
            keyPassword flavorBKeystoreProperties['keyPassword']
            storeFile file(flavorBKeystoreProperties['storeFile'])
            storePassword flavorBKeystoreProperties['storePassword']
        }

        flavorC{
            keyAlias flavorCKeystoreProperties['keyAlias']
            keyPassword flavorCKeystoreProperties['keyPassword']
            storeFile file(flavorCKeystoreProperties['storeFile'])
            storePassword flavorCKeystoreProperties['storePassword']
        }       
    }


    flavorDimensions("default")
    productFlavors{

        flavorA{
            dimension "default"
            applicationId "com.example.flavor.flavorA"
            signingConfig signingConfigs.flavorAConfig
        }

        flavorB{
            dimension "default"
            applicationId "com.example.flavor.flavorB"
            signingConfig signingConfigs.flavorBConfig
        }

        flavorC{
            dimension "default"
            applicationId "com.example.flavor.flavorC"
            signingConfig signingConfigs.flavorCConfig
        }
    }   

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            productFlavors.flavorA.signingConfig signingConfigs.flavorAConfig
            productFlavors.flavorB.signingConfig signingConfigs.flavorBConfig
            productFlavors.flavorC.signingConfig signingConfigs.flavorCConfig

    }
        debug {
            applicationIdSuffix ".debug"
            minifyEnabled false
        }
    }
}

【问题讨论】:

  • 您似乎在使用 Google App Signing。这意味着无论如何你的签名都会被谷歌取代。使用不同的有什么意义?
  • 我明白了,他们有办法防止这种情况吗?因为我是使用 Android Studio 生成密钥库的?

标签: android android-gradle-plugin apk build.gradle android-productflavors


【解决方案1】:

对于任何有同样问题的人。 请检查您输入的口味名称是否正确 在 gradle 和属性文件中。 同样在属性文件中,检查密钥库文件和密码的路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-10
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-12
    • 2021-12-11
    相关资源
    最近更新 更多