天天看點

Error:Execution failed for task ':app:packageRelease'. > Failed to read key key0 from store "C:\User

今天在打包apk的時候出現了問題。如下圖所示,報錯資訊如下:

Error:Execution failed for task ':app:packageRelease'.

> Failed to read key key0 from store "C:\Users\hasee\Desktop\pudong.jks": Cannot recover key

Error:Execution failed for task ':app:packageRelease'. > Failed to read key key0 from store "C:\User

這讓我感到很奇怪,已經到最後一步了,怎麼還報錯。。。。而且以前用這個pudong.jks檔案打包也沒出現錯誤啊,這次是怎麼了。

從這個報錯上來看,好像是從pudong.jks裡讀取key0的時候失敗了。

我的pudong.jks是放在桌面上的,我就在桌面上,按住shift鍵,同時滑鼠右擊,右鍵菜單裡有個在此處打開Powershell視窗,如果你對jks或者keystore檔案是放在某個檔案夾下的,就在那個檔案夾下按住shift鍵,同時滑鼠右擊,在此處打開Powershell視窗,一定要按住shift鍵哦,不然菜單裡是沒有在此處打開Powershell視窗這個選項的。

我要做的就是在Powershell視窗中輸入指令行,檢視jks檔案裡是否有key0這個key alias。

指令行如下keytool -list -v -keystore pudong.jks

其中pudong.jks是你的簽名檔案,有的簽名檔案是.keystore結尾的。

Error:Execution failed for task ':app:packageRelease'. > Failed to read key key0 from store "C:\User

大家可以看到我的key alias是key0,說明我沒填錯啊,那就不是key alias的問題了。

百度一下,有人說是key alias複制過去的時候有空格,但是我看了一下我的key0是沒有空格的啊。

Error:Execution failed for task ':app:packageRelease'. > Failed to read key key0 from store "C:\User

最後經過排查是密碼輸錯了。就是說key store password 和key password的密碼一定要輸對。不然就會報那個錯。

如果本文對你有幫助的話,麻煩在左側點個贊,謝謝支援!