Issue
I am trying to upload a completely new app to the play store but am being met with the error "Your Android App Bundle is signed with the wrong key. Ensure that your App Bundle is signed with the correct signing key and try again". I have tried my best to follow and understand the instructions and believe I have followed them.
From https://developer.android.com/studio/publish/app-signing#generate-key I have done these steps and created a new keystore.jks file. I then continue to the next step and sign my app with that same key, providing the same password used to create it. I left they key alias as key0 which was the default, and checked off 'Export encrypted key for enrolling published apps in Google Play App Signing', though I have not had a chance to use the file it exports. I made sure the build type was set to release, not debug and made my app-release.aab file.
I then continue onto the next section for 'Opt in to app signing by Google Play'/'Opt in a new app'. Step 1 is covered by the steps I've taken previously. I then sign into the developer account and navigate to the app I set up (there is only one associated with the account), and go to the App Releases page from the navigation on the right.
I scroll down to 'Internal test track' and edit release. It is set to edit not create because initially I tried to upload a React Native 0.57 app and found that I had to update it to a more recent version before the store would accept it. I kept the name and 'what's new in this release?' section but removed the app that was there previously and saved the page. I also made sure to remove this previous version from the Artifact library, which is now empty.
When I try to upload my app-release.aab file I am told "Your Android App Bundle is signed with the wrong key. Ensure that your App Bundle is signed with the correct signing key and try again: SHA1: [...]". This is where I am stuck now.
Things I have researched and tried:
- I have tried cleaning the project and recreating the keystore file and rebuilding the app with that. Same wrong key result.
- I have changed the location of the .jks file in case there some caching going on in. Same wrong key result.
- I have tried removing the debug.keystore file from android/app/debug.keystore, AS did not like that and would not build the bundle successfully without it
- I have checked for a few debuggable properties that may have been set within the .gradle file(s), debuggable = true, and testCoverageEnabled = true (Or some other value). Neither of these were set.
- I have made sure that the same password was being used in creation through the above steps to create and sign. Same wrong key result.
- Crying and giving up. Same wrong key result.
- I have read that having the signingConfig specified anywhere in your gradle files will override the choice you make during the bundle creation and have commented that out for release buildtypes. After uploading I was told my app was not signed.
- Instead of using AS, I followed this guide: https://facebook.github.io/react-native/docs/signed-apk-android and made an appname.keystore file, signingConfigs { release {..}} entry for that and creating the .aab through command line via gradlew bundleRelease as instructed, then uploaded that. Same wrong key result.
I am absolutely, completely lost. I have no idea what to do next. Everything I have found and tried has failed, I cannot find any more things to try. Please help me.
Below are my gradle files:
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=[...]
Solution
So, it sounds as if you had created and signed a React Native version of your app, with the same bundle identifier, and tried, and/or succeeded to upload the binary to your Google Play console. Now, you are trying to upload another binary, signed with a different key, but with the same bundle identifier. Is that correct?
If so, you are going to have to change the App Name and Bundle Identifier to something brand new (unless you have found a way to completely delete all previous references to your project from your console and 'add' instead of 'edit', which I don't think is possible).
Additionally, you should check what date you used as an expiration date for your 'Release' keystore. Typically, they have a maximum date that they suggest you use, which is something like 100 years in the future, but you'd have to google the exact date they suggest. If you expire your Release keystore too soon, you won't be able to build Release builds after it expires.
Answered By - Michael Dougan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.