keystore not found for signing config 'release'.-- React native

Kartiikeya picture Kartiikeya · Dec 29, 2017 · Viewed 68.4k times · Source

I'm trying to generate a Signed APK for react native project. Followed steps from android and react-native documentation.

my Build.gradle file

android {
compileSdkVersion 23
buildToolsVersion '26.0.2'

defaultConfig {
    applicationId "com.appmobile"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
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
        }
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
        // minifyEnabled enableProguardInReleaseBuilds
        // proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
// buildTypes {
//     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:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        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
        }
    }
}

}

I have placed keystore file in Android/app directory

my grade.properties

    android.useDeprecatedNdk=true
MYAPP_RELEASE_STORE_FILE=sampleReleasekeyStore.jks
MYAPP_RELEASE_KEY_ALIAS=*****
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****

when executing cd android && ./gradlew assembleRelease.

Its throwing Build failed

Execution failed for task ':app:validateSigningRelease'. Keystore file /Users/username/Projects/appMobile/android/app/sampleReleasekeyStore.jks not found for signing config 'release'.

I'm using a Mac environment. Please let me know where I'm going wrong.

Answer

AlexPad picture AlexPad · Jul 23, 2019

The problem in this case is the path. As you have already mentioned above, enter the key in the app folder. Then in your .properties, don't name the whole path, because you are already in your project / app .. you just have to enter the name of the key:

storePassword=my_password
keyPassword=my_password
keyAlias=key
storeFile=key.jks