14

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?

alex2k8
  • 42,496
  • 57
  • 170
  • 221

4 Answers4

11

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;

    ...
}
alex2k8
  • 42,496
  • 57
  • 170
  • 221
  • 6
    [sigh] yes, the Android OS likes putting random limitations without a good enough reason. – Franci Penov Feb 21 '11 at 17:05
  • 1
    Inside the C code from the Android NDK used internally by the Java VM on Android you can find this in the usr/include/sys/system_properties.h header: https://gist.github.com/mnemonicflow/6c689f30899a654867b3#file-system_properties-h-L38 `#define PROP_NAME_MAX 32 #define PROP_VALUE_MAX 92` In C the additional byte is used to termine the string with a '\0' – Alex Bitek Feb 24 '16 at 20:12
3

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;
    ...
}
Jeremy Frank
  • 743
  • 1
  • 7
  • 10
2

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.

idoitlpg
  • 21
  • 1
0

Maybe using redirection?

Set small property which will hold file name for conf file:

setprop confFileName "myConf.yml"

in that conf file have all your big property names and values.

vmiheer
  • 147
  • 9