React Native Generating Signed APK "KeyStore file not set for signing config release"

I am trying to generate a signed APK. I have my password.keystore file located in \Dictionary\android\app and when i ran gradlew assembleRelease on cmd, the error:

Execution failed for task ':app:validateSigningRelease'.

Keystore file not set for signing config release

Where should I store my password.keystore file? Because when I commented off the if (project.hasProperty("password.keystore") { it seems to work but with the following error instead:

Unable to process incoming event 'ProgressComplete ' (ProgressCompleteEvent)

How should I write my if condition or where should I store the password.keystore file?

The source code is as follows:

signingConfigs {
  release {
    if (project.hasProperty("password.keystore")) {
      storeFile file("password.keystore")
      storePassword "password"
      keyAlias "username"
      keyPassword "password"
    }
  }
}

Answers


The keystore file has to be in the android/app folder.

The message 'Keystore file not set for signing config release' has to do that there is no signingConfig in the android/app/build.gradle file.

buildTypes {
    release {
        // other settings
        signingConfig signingConfigs.release
    }
}

For testing you can just hard coded the settings in the android/app/build.gradle, instead off set it in the gradle.properties. This was fixing for me the problem with 'Keystore was tampered with, or password was incorrect'

  signingConfigs {
    release {
        //if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file("key.keystore")
            storePassword "****"
            keyAlias "myKey"
            keyPassword "****"
       // }
    }
}

I have found a solution!

If you have followed React Native's official instructions, just like me, you add following to your gradle.properties

MYAPP_RELEASE_STORE_FILE=<your-app>.keystore
MYAPP_RELEASE_KEY_ALIAS=<keystore-alias>
MYAPP_RELEASE_STORE_PASSWORD=<password>
MYAPP_RELEASE_KEY_PASSWORD=<password>

And then comes the part that I totally misunderstood.

In the app/build.gradle-file, you are not supposed to replace the strings. If your gradle.properties is like the one I pasted over, your app/build.gradle should look like this:

signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}

What I originally did was replacing the strings (i.e. 'MYAPP_RELEASE_STORE_FILE' with the path to my keystore-file), but you are not supposed to replace any of the variables at all. I guess you could see the connection between the strings we created in gradle.properties and the release-config we have made in app/build.gradle.

Remember to have your .keystore-file inside android/app as well.


In my case, my project was on RN version 0.59 while I was using 0.60 RC documentation. So inside app/build.gradle

If version 0.59 :

if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {

If version 0.60 :

if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {

The difference is the change from RELEASE to UPLOAD


I had exact same issue. Turn out I forgot to edit gradle.properties file. It should look like this:

android.useDeprecatedNdk=true

MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias

project.hasProperty will be looking in your gradle.properties file for a variable named password.keystore.

Go into ~/.gradle and see if you have a gradle.properties file, if you do, make sure the variable password.keystore is there, it should point to your keystore file: password.keystore=password.keystore.

Although you should name it something different, like MYAPP_RELEASE_STORE_FILE=password.keystore. Then when you run ./gradlew assembleRelease your project will have the property it's looking for and the following will resolve true and allow gradlew to set all the signingConfigs.release properties:

if (project.hasProperty(MYAPP_RELEASE_STORE_FILE)) {
    storeFile file(...)
    storePassword your_password_property
    ...
}

After exploring all answers regarding this issue, none of the answer helped!

So tried below experiment and it helped!!!!

Place the my-release-key.keystore file under the android directory in your project folder.


I actually prefer to store these parameters outside the app repo using environment variables since it contains sensitive information like password, etc.

signingConfigs {
    release {
        if (System.env.MYAPP_RELEASE_STORE_FILE != null) {
            storeFile       file(System.env.MYAPP_RELEASE_STORE_FILE)
            storePassword   System.env.MYAPP_RELEASE_STORE_PASSWORD
            keyAlias        System.env.MYAPP_RELEASE_KEY_ALIAS
            keyPassword     System.env.MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}

Once this is done, I can just load up a bash script which has the details like

# path to my keystore
export MYAPP_RELEASE_STORE_FILE=/path/to/key.file
# ...

This way the signing config is completely isolated from the repo. This prevents you from making accidental commits with your secrets.


Make sure you have placed your .keystore file inside app folder and do gradle changes like below:

    signingConfigs {
    release {
        storeFile file(RELEASE_STORE_FILE)
        storePassword RELEASE_STORE_PASSWORD
        keyAlias RELEASE_KEY_ALIAS
        keyPassword RELEASE_KEY_PASSWORD
    }
}

Make sure alias name used in gradle.properties is same as the one used while creating keystore ( using keytool )


Need Your Help

Is String a primitive type?

c# .net vb.net string primitive-types

I am curious about the string and primitive types. Article like this says string is primitive type. However second article on MSDN does not list string as primitive type.

Clear contents of cells in VBA using column reference

excel vba excel-vba

I am trying to get a piece of code to clear the data in some cells, using the column references. I am using the following code: