Android Studio提取字符串资源自动生成名称功能失效,如何恢复?
Hey there! I’ve run into this exact issue before, so let me break down what’s likely happening and how to get that auto-generate functionality back up and running—it hasn’t been removed, just probably glitched or misconfigured.
Common Fixes to Try:
Clear Android Studio Caches (Most Likely Fix)
Corrupted caches are the #1 culprit for weird little UI/functionality glitches like this. Here’s how to fix it:- Go to
File > Invalidate Caches... - Check the box for Clear file system cache and local history
- Click
Invalidate and Restart
Once Studio reboots, try extracting a string again—9 times out of 10 this brings the auto-name generation back.
- Go to
Verify the Extract String Intention is Enabled
Sometimes intentions get accidentally disabled without you noticing:- Open
Settings > Editor > Intentions - Expand the Android section
- Make sure the box next to Extract string resource is checked
If it was unchecked, enable it and restart Studio to apply changes.
- Open
Check Your strings.xml for Errors
If yourres/values/strings.xmlhas syntax issues (like unclosed tags, invalid characters, or duplicate names), Android Studio might fail to auto-generate new names. Open the file and look for any red squiggles—fix those errors first, then try extracting again.Review String Resource Naming Rules
If you’ve modified the naming conventions, it might break auto-generation:- Go to
Settings > Editor > Code Style > Android > String Resources - Check the Naming tab—make sure the rules are set to something sensible (like using snake_case, which is the default)
If you’ve changed these to an invalid format, reset to defaults and test again.
- Go to
Update/Downgrade Android Studio
Occasional bugs creep into specific Studio versions (I saw this pop up briefly in the Electric Eel update cycle). Try updating to the latest stable version, or if you’re on a beta, roll back to a known-stable release like Giraffe or Hedgehog.
Final Note
If none of these work, try creating a new test project and see if the auto-generate works there—if it does, the issue is specific to your existing project, and you might need to reimport it or check for project-level configuration corruption.
内容的提问来源于stack exchange,提问作者Kenny Wyland

