Saved by the Logs: How to Recover a Forgotten Keystore Password via IDE Build Logs.
kidneyweakx
December 6, 2025 (Updated: December 19, 2025)
The greatest distance in the world is when the password is right in the IDE, but I can't see it
I believe many Android developers have experienced this frustrating moment: you're preparing to package a Release version, only to realize you've forgotten the Keystore password you haven't entered in ages! Although Android Studio thoughtfully provides a "Remember passwords" option and fills it in automatically, it only shows you •••••••• and refuses to reveal the plain text.
Do you really have to apply to Google to reset your Upload Key or resort to brute force?
Don't worry! As long as Android Studio still remembers the password, we can "intercept" it through Gradle.
# How It Works
When we execute Generate Signed Bundle / APK, Android Studio must "inject" the password into Gradle behind the scenes so that Gradle can perform the signing. We simply need to plant a snippet of code in build.gradle to listen for this injection and print the password to the log.
# Implementation Steps (Kotlin DSL Version)
Step 1: Plant the Interception Script
Open your app-level build.gradle.kts file and paste the following code at the very end of the file:
Kotlin
// ==========================================
// Password Interception Script (MUST DELETE AFTER USE!!!)
// ==========================================
project.afterEvaluate {
val storePass = project.properties["android.injected.signing.store.password"]
val keyPass = project.properties["android.injected.signing.key.password"]
if (storePass != null || keyPass != null) {
println("\n========== [GOT IT! Passwords are here] ==========")
println("Store Password: $storePass")
println("Key Password: $keyPass")
println("=========================================\n")
}
}
Step 2: Trigger the Build
- Click on the top menu in Android Studio: Build > Generate Signed Bundle / APK....
- Follow the normal process and select your Keystore path.
- The crucial step: Ensure that "Remember passwords" is checked (this is required for the IDE to output the passwords).
- Click Next > Create to start the packaging process.
Step 3: Check the Log
Once the build starts, open the Build tab at the bottom and click the "Toggle view" (list icon) on the left to switch to plain text mode.
Search through the logs for the keyword: GOT IT.
You will see something like this:
Plaintext
========== [GOT IT! Passwords are here] ==========
Store Password: your_lost_password_123
Key Password: your_lost_password_123
=========================================
Step 4: Backup and Destroy (Most Important!)
Congratulations on recovering your password!
- Immediately record the password in 1Password or another secure location.
- Delete the code snippet you just added to
build.gradle.ktsright away. - If this code was accidentally committed to Git, be sure to modify your Git history or treat the password as compromised.
# Conclusion
This method leverages Gradle's project.properties mechanism to directly read parameters injected by the IDE. It's safe, fast, and doesn't require installing any cracking tools. I hope this helps fellow "goldfish-brained" developers!
Related Articles
No File is an Island: Unraveling Swift Dependencies and Architecture
> 在 Swift 的世界中,我們習慣了強大的 Xcode 和簡潔的語法,但隨著專案規模的成長,一個隱形的怪獸會開始在程式碼中徘徊:那就是失控的依賴關係
Hexo 升級 V5 排除疑難雜症
> 因為剛好把電腦重灌,然後這個 blog 就躺在D槽等著我幫他換新的環境,然後他就被我快樂的升級了。 hexo 更新 v5.0 hexo 更新到 V5 的步驟相當容易 就可以自動更新了,但是版本大更新,往往都會附帶一些小問題,像他就給我了幾個warning 更新後 Error 解決方法 修改\ config.yml的部分成新版的,原始external\ link只有true的選項,更新後可決定是否開...
C# 用 VID 和 PID 自動連線 serialport
> 原本 C 的 serial port function官方範例,是類似這樣的 這種方法每次開啟都還要再去跟改port相當的麻煩,所以就找了別人針對windows寫的function,再返回靜態的 port string 給 ,效果相當好。 完整內容可參照下方連結😁 code來源