I want to change language via ADB. I try:
adb shell setprop persist.sys.language fr;setprop persist.sys.country CA;stop;sleep 5;start
but I get errors:
setprop: command not found
stop: missing job name
Try `stop --help' for more information.
start: missing job name
Try `start --help' for more information.
what is wrong? I want to do this on physical device
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.
The solution to do it without rooting. You can use something like this the below function. The function goes into settings and exercises the UI to change the locale settings.
https://github.com/dtmilano/AndroidViewClient/blob/480ab93dbd01296a68c1ce7109ceb8275d1ed8a7/src/com/dtmilano/android/viewclient.py#L1302
The tricky part is to get to the right language when you are in a different language. You would think the language always maintain the same index in the list, but unfortunately not. So you have to have a solution like this.
Con: You my have to tweak it a little for handling different phones, the settings may have a different order.
On Emulator: When changed language manually, it stopped working and had to do wipe data of Emulator in AVD manager to make it work again.
And the script used:
May add ;sleep 20 in the end if some commands in script below this command depend on device to be ready.
Run through the following steps:
Root the emulator, by running the command:
Run the following shell command through
adb
:then, exit the shell which restarts the emulator.
Locales we need for screenshots:
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):and the error messages you see are from local shell (i.e. there is no
setprop
executable on your system andstart
andstop
commands have non-optional parameters.the correct command would be
or in more recent Android versions:
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: