Change Device language via ADB
Your errors have nothing to do with adb
. You just lack understanding of how your local shell processes your command. What you are doing is running these commands locally (on your PC):
adb shell setprop persist.sys.language fr
setprop persist.sys.country CA
stop
sleep 5
start
and the error messages you see are from local shell (i.e. there is no setprop
executable on your system and start
and stop
commands have non-optional parameters.
the correct command would be
adb shell "setprop persist.sys.language fr; setprop persist.sys.country CA; setprop ctl.restart zygote"
or in more recent Android versions:
adb shell "setprop persist.sys.locale fr-CA; setprop ctl.restart zygote"
You can change the locale/language for testing purposes without rooting the device, also on newer (4.2+) devices. You have to create an application that changes the device locale. Or, you can use a helper app, e.g. ADB Change Language.
Next, on 4.2+ devices, you have to use grant the app CHANGE_CONFIGURATION permission via adb, adb shell pm grant <package_name> android.permission.CHANGE_CONFIGURATION
.
Finally, you can use adb commands (launch activity) to switch locale.
There is few solutions.It works for me.
1.
adb shell am start -a android.settings.LOCALE_SETTINGS
(You could see the language menu, then choose language by appium)
2.
download adbchangelanguage on google store
adb shell pm grant net.sanapeli.adbchangelanguage android.permission.CHANGE_CONFIGURATION
adb shell am start -n net.sanapeli.adbchangelanguage/.AdbChangeLanguage -e language zh -e country TW
https://gist.github.com/douglasselph/b9998e69998759c6cceec1df1aa96ac5
3.
using appium then set desired capabilities (language and locale) http://appium.io/docs/en/writing-running-appium/caps/
This is all over the place, to put it simply
setprop will only work on an AVD or a rooted physical device
The alternative is to use the settings in the Launcher.
Rooted device or AVD this works:
<android-sdk path>/platform-tools/adb shell
root@generic:/ # getprop persist.sys.language
getprop persist.sys.language
en
root@generic:/ # setprop persist.sys.language fr
setprop persist.sys.language fr
root@generic:/ # setprop persist.sys.country CA
setprop persist.sys.country CA
root@generic:/ # stop
stop
root@generic:/ # start
start
root@generic:/ # sleep 5
sleep 5
root@generic:/ # getprop |grep lang
getprop |grep lang
[persist.sys.language]: [fr]
root@generic:/ # getprop |grep country
getprop |grep country
[persist.sys.country]: [CA]
root@generic:/ #
Run through the following steps:
- Create emulator with google APIs Intel x86
-
Root the emulator, by running the command:
adb root
-
Run the following shell command through
adb
:adb -e shell "su root; setprop persist.sys.locale pt-PT; stop; sleep 2; start”
then, exit the shell which restarts the emulator.
-
Locales we need for screenshots:
de_DE en_EN fr_FR ko_KO pt_PT es_ES ja_JA