提问者:小点点

对于这个问题,我已经尝试了所有其他的答案:你的Android应用包用错误的密钥签名。确保您的应用程序包已签名[..]


我正在尝试上传一个全新的应用程序到play store,但遇到错误“您的Android应用程序包是用错误的密钥签名的。请确保您的应用程序包是用正确的签名密钥签名的,然后再试一次”。我已经尽我最大的努力去遵循和理解这些指示,并且相信我已经遵循了这些指示。

在https://developer.android.com/studio/publish/app-signing#generate-key中,我已经完成了这些步骤,并创建了一个新的keystore.jks文件。然后,我继续下一步,并使用相同的密钥签署我的应用程序,提供相同的密码用于创建它。我把他们的密钥别名留为key0,这是默认的,并且勾选了“在Google Play应用签名中为注册发布的应用导出加密密钥”,尽管我没有机会使用它导出的文件。我确保构建类型设置为release,而不是debug,并创建了app-release.aab文件。

然后,我继续下一节的‘选择在应用签署由Google Play’/‘选择在一个新的应用’。步骤1包含了我前面所采取的步骤。然后我登录到developer帐户并导航到我设置的应用程序(只有一个与该帐户相关联),然后从右侧的导航转到应用程序发布页面。

我向下滚动到“内部测试轨道”并编辑发布。它被设置为edit,而不是create,因为最初我试图上传一个React Native 0.57应用程序,发现我必须更新它到一个更新的版本,商店才会接受它。我保留了名字和‘这个版本有什么新内容?’节,但删除了之前存在的应用程序并保存了该页面。我还确保从工件库中删除这个以前的版本,现在工件库是空的。

当我尝试上传app-release.aab文件时,我被告知“您的Android应用包使用错误的密钥签名。请确保您的应用包使用正确的签名密钥签名,然后重试:sha1:[...]”。这就是我现在被困的地方。

我研究和尝试过的事情:

  1. 我尝试过清理项目,重新创建密钥库文件,并用它重新创建应用程序。同样错误的键结果。
  2. 我已经更改了.jks文件的位置,以防出现缓存。同样错误的键结果。
  3. 我已经尝试从android/app/debug.keystore中删除debug.keystore文件,因为我不喜欢这样做,没有它就无法成功构建包
  4. 我检查了一些可能已在.gradle文件中设置的可调试属性,debuggable=true和testCoverageEnabled=true(或其他值)。这两个都没有设置。
  5. 我已经通过上面的创建和签名步骤确保在创建过程中使用了相同的密码。同样错误的键结果。
  6. 哭着放弃。同样错误的键结果。
  7. 我已经读到在gradle文件中的任何地方指定signingConfig将覆盖您在创建捆绑包期间所做的选择,并在发布BuildTypes时注释了这一点。上传后,我被告知我的应用程序没有签名。
  8. 我没有使用AS,而是遵循了以下指南:https://facebook.github.io/react-native/docs/signed-apk-android,并创建了一个appname.keystore文件signingConfigs{release{..}}条目,然后通过命令行通过gradlew bundleRelease按指示创建.aab,然后上传。同样错误的键结果。

我绝对,完全迷失了。我不知道下一步该做什么。我所发现和尝试的一切都失败了,我再也找不到可以尝试的东西了。请帮帮我.

以下是我的分级文件:

Android\app\build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
 *   bundleCommand: "ram-bundle",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.[..]"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        missingDimensionStrategy 'react-native-camera', 'general'
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.android.gms:play-services-gcm:12.+"

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.android.support:appcompat-v7:XX.X.+'

    implementation 'com.android.support:multidex:1.0.3'

    androidTestImplementation 'androidx.annotation:annotation:1.0.0'

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

Android\build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        googlePlayServicesVersion = "16.+"
        firebaseVersion = "17.3.4"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.5.2')
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

project.configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
                && !details.requested.name.contains('multidex') ) {
            details.useVersion "26.+"
        }
        if (details.requested.group == 'com.google.android.gms'
        && !details.requested.name.contains('multidex') && (
            !details.requested.name.contains('play-services-stats') ||
            !details.requested.name.contains('play-services-vision-image-label') ||
            !details.requested.name.contains('play-services-clearcut') ||
            !details.requested.name.contains('play-services-flags') ||
            !details.requested.name.contains('play-services-phenotype')
            )) {
            details.useVersion "12.+"
        }
        if (details.requested.group == 'com.google.android.gms'
        && !details.requested.name.contains('multidex') && (
            details.requested.name.contains('play-services-stats') ||
            details.requested.name.contains('play-services-vision-image-label') ||
            details.requested.name.contains('play-services-clearcut') ||
            details.requested.name.contains('play-services-flags') ||
            details.requested.name.contains('play-services-phenotype')
            )) {
            details.useVersion "+"
        }
        if (details.requested.group == 'com.google.firebase'
        && !details.requested.name.contains('multidex') && details.requested.name.contains('firebase-messaging')) {
            details.useVersion "12.+"
        }
    }
}

ext {
    googlePlayServicesVersion = "+" // default: "+"
    firebaseVersion = "+" // default: "+"
    // Other settings
    compileSdkVersion = 28 // default: 23
    buildToolsVersion = "28.0.3" // default: "23.0.1"
    targetSdkVersion = 28 // default: 23
    supportLibVersion = "28.0.0"
}

Gradle.properties:

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

org.gradle.jvmargs=-Xmx4608m
android.useAndroidX=true
android.enableJetifier=true

MYAPP_UPLOAD_STORE_FILE=[...].keystore
MYAPP_UPLOAD_KEY_ALIAS=[...]
MYAPP_UPLOAD_STORE_PASSWORD=[...]
MYAPP_UPLOAD_KEY_PASSWORD=[...]

共1个答案

匿名用户

所以,听起来就好像你已经创建并签署了应用程序的React原生版本,使用相同的bundle标识符,并尝试和/或成功地将二进制文件上传到了Google Play控制台。现在,您正在尝试上传另一个二进制文件,它使用不同的密钥签名,但使用相同的包标识符。那是正确的吗?

如果是这样的话,你将不得不把应用程序名称和包标识符更改为全新的(除非你已经找到了一种方法,可以从控制台中完全删除所有以前对你的项目的引用,并且用“add”代替“edit”,我认为这是不可能的)。

此外,您应该检查您使用了什么日期作为您的“发布”密钥库的过期日期。通常,他们有一个最大的日期,他们建议你使用,大约是100年的未来,但你必须谷歌他们建议的确切日期。如果您的发行版密钥存储库过期得太快,那么在它过期之后您将无法构建发行版构建。