Android Go Launcher3使用SystemProperties模块编译报错
解决方案
- 修改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
- 通过反射机制
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;
}