Android源码应用调用SystemProperties编译报错

Android Go Launcher3使用SystemProperties模块编译报错

解决方案

  1. 修改Android.mk
    将Android.mk中LOCAL_SDK_VERSION := current注释掉
#LOCAL_SDK_VERSION := current
LOCAL_MIN_SDK_VERSION := 21
LOCAL_PACKAGE_NAME := MtkLauncher3Go
LOCAL_PRIVILEGED_MODULE := true
LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3Go MtkLauncher3
  1. 通过反射机制
public static String getSystemProperty(String property, String defaultValue) {
       try {
            Class clazz = Class.forName("android.os.SystemProperties");
            Method getter = clazz.getDeclaredMethod("get", String.class);
            String value = (String) getter.invoke(null, property);
            if (!TextUtils.isEmpty(value)) {
                return value;
            }
        } catch (Exception e) {
            Log.d(TAG, "Unable to read system properties");
        }
        return defaultValue;
 }

你可能感兴趣的:(Android源码应用调用SystemProperties编译报错)