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
Hexo升級V5排除疑難雜症
> 因為剛好把電腦重灌,然後這個blog就躺在D槽等著我幫他換新的環境,然後他就被我快樂的升級了。
C# 用VID和PID自動連線serialport
> 原本C#的serial port function官方範例,是類似這樣的
Golang Json解析問題 Struct字首大小寫
> 其實這還蠻有趣的,最近在玩golang的爬蟲,高效率的編譯和好用的colly真的還挺好上手的,但是畢竟爬蟲還是要encode成Json才好做跨平台處理。