'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"
    }
  }
}


Solution 1:[1]

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 "****"
       // }
    }
}

Solution 2:[2]

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

Solution 3:[3]

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.

Solution 4:[4]

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
    ...
}

Solution 5:[5]

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.

Solution 6:[6]

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

Solution 7:[7]

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

Solution 8:[8]

the gradle.properties file i placed in android/gradle.properties and it worked for me, looks like in latest react .gradle/gradle.properties file if we place it in this location it does not pick from their.

Solution 9:[9]

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.

Solution 10:[10]

Use ./gradlew bundleRelease than ./gradlew assembleRelease

Solution 11:[11]

Try to do like this :

           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'
        }
    }

Solution 12:[12]

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
    }
}

Solution 13:[13]

In my case in my gradle.properties file was like

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

and in my build.gradle file

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
            }
        }

I was using RELEASE in my gradle.properties instead of UPLOAD. Just changed the RELEASE to UPLOAD in gradle.properties and issue was gone.