如何在Android应用/APK中获取所有显示文本以进行人工翻译?
Great question—pulling all UI text from an Android app is a common task for localization, and there are reliable methods depending on whether you have access to the source code or just the APK.
1. If You Have the Source Code
This is the simplest path by far:
- Navigate to your project’s
res/values/directory. - Open
strings.xml—this file holds nearly all static UI text (buttons, labels, error messages, onboarding copy, etc.). - For apps that already support multiple languages, check subdirectories like
values-es/orvalues-fr/for existing translations, but your core focus will be the basestrings.xmlfile.
2. If You Only Have the APK (No Source Code)
You’ll need to decompile the APK to access its resource files:
- Use Apktool, a widely used open-source tool for reverse-engineering Android apps.
- Install Apktool, then run this command in your terminal:
apktool d your_app.apk - This creates a folder with the app’s decompiled resources. Head to
res/values/strings.xmlto grab all static text. - Note: Some apps obfuscate code, but
strings.xmlusually stays readable since it’s critical for the app’s UI functionality.
3. Capturing Dynamic/Server-Sent Text
If the app pulls text from an API or generates it on the fly (not stored in strings.xml), you’ll need to capture it as you navigate every screen:
- Android Studio Layout Inspector: Connect your device or emulator, open the app, and use the Layout Inspector to inspect each screen’s elements. It shows the text of every UI component in real time.
- ADB UI Dump: Run this command to dump the current screen’s UI hierarchy to an XML file:
Pull the file to your computer withadb shell uiautomator dump /sdcard/ui_dump.xmladb pull /sdcard/ui_dump.xml, then parse it to extract alltextattributes. Repeat this for every screen in the app.
Pro Tip
For a more automated approach to capture dynamic text, write a simple UI test using Espresso that navigates through all app flows and logs every text element it encounters. This saves a ton of time if the app has dozens of screens.
内容的提问来源于stack exchange,提问作者Lorem Ipsum

