Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I overcome the property length limitation of the "adb shell setprop"

I get an error when I try set a value for property with name >= 32 characters

adb shell setprop 01234567890123456789012345678901 VALUE

Error:

could not set property

This works fine

adb shell setprop 0123456789012345678901234567890 VALUE
adb shell getprop 0123456789012345678901234567890
VALUE

Is there any way to set properties with longer names?

like image 471
alex2k8 Avatar asked Feb 21 '11 16:02

alex2k8


3 Answers

It looks like there would be no way to bypass this limitation. I see the same rules in android java sources.

public class SystemProperties
{
    public static final int PROP_NAME_MAX = 31;
    public static final int PROP_VALUE_MAX = 91;

    ...
}
like image 186
alex2k8 Avatar answered Nov 20 '22 02:11

alex2k8


Update: The system property name limit of 32 characters was removed in Android O. You are free to have longer names now.

public class SystemProperties {
    /**
     * Android O removed the property name length limit, but com.amazon.kindle 7.8.1.5
     * uses reflection to read this whenever text is selected (http://b/36095274).
     */
    public static final int PROP_NAME_MAX = Integer.MAX_VALUE;
    public static final int PROP_VALUE_MAX = 91;
    ...
}
like image 31
Jeremy Frank Avatar answered Nov 20 '22 03:11

Jeremy Frank


I also faced same problem. as the answer mentioned above it's not possible use the NAME which longer than 31. so i change package name to shorter than 31 and it works now.

like image 2
idoitlpg Avatar answered Nov 20 '22 03:11

idoitlpg