Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android and gradle uses old non-existing keystore when signing app

Tags:

I tried to sign my new android app using data from some old keystore named "keystore.keystore". It couldn't recover key so I deleted that keystore from disk and created a new one, named "keystore.jks".

Then I added the following to build.gradle, following guide from page https://developer.android.com/studio/build/build-variants#signing:

signingConfigs {
    release {
        storeFile file("C:\\SomeDirectory\\keystore.jks")
        storePassword "mypassword123"
        keyAlias "key"
        keyPassword "mypassword123"
    }
}

buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

Then I went to Build / Generate Signed Bundle/APK menu option in Android Studio. It didn't pick information about keystore, key or alias from the above build.gradle file, so I entered it again manually in the dialog window.

After pressing Next, the task completed with the following error:

"C:\SomeDirectory\keystore.keystore (The system cannot find the file specified)".

Notice the name of the keystore, it's the old name. Where does it come from???

So I opened cmd.exe and ran this: "gradlew.bat assembleRelease". There was similar error:

Task :app:packageRelease FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:packageRelease'. java.io.FileNotFoundException: C:\SomeDirectory\keystore.keystore (The system cannot find the file specified)

Invalidating caches/restarting doesn't help.

Why is gradle referring to the old keystore name, how to make it use the new keystore?

like image 326
camcam Avatar asked Jan 25 '19 01:01

camcam


2 Answers

gradlew clean will make gradle use the new one

like image 148
Tomsdev Avatar answered Nov 11 '22 10:11

Tomsdev


I faced the same issue today.

What worked for me was to delete the app/build/intermediates/signing_config/release/out/signing-config.json file between builds (I don't know why this works).

like image 45
Louis Zawadzki Avatar answered Nov 11 '22 09:11

Louis Zawadzki