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

六月ゝ 毕业季﹏ 提交于 2019-11-30 01:32:28

问题


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 Mac environment. Please let me know where I'm going wrong.


回答1:


  1. Open Android Studio
  2. Drag and drop your keystore file over app folder
  3. Click in File -> Sync project



回答2:


It's works for me!

  1. https://facebook.github.io/react-native/docs/signed-apk-android.html
  2. Open terminal like the picture (Library -> Android -> ...)
  3. keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
  4. xxxx.keystore in current folder.




回答3:


Try to remove .jks from MYAPP_RELEASE_STORE_FILE, it worked for me.

MYAPP_RELEASE_STORE_FILE=sampleReleasekeyStore



回答4:


go to your App Folder

cd android
cd app

and use this command to generate your debug key

keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

For Release APK

keytool -genkey -v -keystore release.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000




回答5:


I noticed Gradle always look for this file in android/app path. (Hardcoded maybe)

In your case put sampleReleasekeyStore.jks in the path;

/Users/username/Projects/appMobile/android/app/

TIP: Just look at the error and put your file inside folder specified in the error.




回答6:


Just add rootProject.File to storeFile to access the keystore.

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



回答7:


In my case this error was triggered when I tried to open on MacOS a project created in Windows.

Error was showing even if the keystore file was added to app folder.

Android Studio seemed to ignore entirely the myProject/android/gradle.properties file

I had to set the local ~/.gradle/gradle.properties file as below

MYAPP_RELEASE_STORE_FILE=<file-release.keystore>
MYAPP_RELEASE_KEY_ALIAS=<key-alias>
MYAPP_RELEASE_STORE_PASSWORD=<password>
MYAPP_RELEASE_KEY_PASSWORD=<keyPassword>



回答8:


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


来源:https://stackoverflow.com/questions/48017376/keystore-not-found-for-signing-config-release-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!