已尝试找到此问题的所有其他答案:您的Android应用程序捆绑包使用错误的密钥签名。确保您的应用捆绑包已签名[..]

问题描述 投票:0回答:1

我正在尝试将一个全新的应用上传到Play商店,但遇到错误“您的Android应用捆绑包使用了错误的密钥签名。请确保您的应用捆绑包使用正确的签名密钥签名,然后重试” 。我已尽力遵循并理解了说明,并相信我已遵循它们。

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

然后我继续进入下一部分“选择加入Google Play应用签名” /“ Opt in a new app”。我先前采取的步骤涵盖了步骤1。然后,我登录到开发人员帐户并导航到我设置的应用程序(只有一个与此帐户相关联的应用程序),然后从右侧导航键转到“应用程序发布”页面。

我向下滚动到“内部测试轨道”并编辑发布。设置它为“不创建”,因为最初我尝试上传React Native 0.57应用程序时发现我不得不将其更新为更新的版本,然后商店才会接受它。我保留了名称,并保留了“此版本中的新功能?”部分,但删除了之前存在的应用并保存了页面。我还确保从Artifact库中删除此先前版本,该库现在为空。

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

我研究并尝试过的东西:

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

我绝对完全迷失了。我不知道下一步该怎么做。我找到并尝试的所有操作都失败了,我找不到其他可以尝试的东西。请帮助我。

下面是我的gradle文件:

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=[...]
android react-native android-studio gradle google-play
1个回答
0
投票

因此,听起来好像您已经使用相同的捆绑包标识符创建并签署了应用的React Native版本,并尝试和/或成功将二进制文件上传到您的Google Play控制台。现在,您正在尝试上传另一个二进制文件,该二进制文件使用不同的密钥签名,但是具有相同的包标识符。正确吗?

[如果是这样,您将不得不将App Name和Bundle Identifier更改为全新的名称(除非您找到了一种方法,可以从控制台中完全删除以前对项目的所有引用,然后使用“ add”而不是“ edit” ,我认为这是不可能的)。

© www.soinside.com 2019 - 2024. All rights reserved.