我们在修改Android源码时候,可能会用到android.os.SystemProperties这个类,但是这个类是系统才能调用的。
有两种办法来解决这种问题:
1.通过Java反射机制:
try {
@SuppressWarnings("rawtypes")
Class classz = Class.forName("android.os.SystemProperties");
@SuppressWarnings("unchecked")
Method method = classz.getMethod("get", new Class[] { String.class, String.class });
Object obj = method.invoke(null, new Object[] { KEY_PROPERTY_SUPPORT_GPS, TRUE} );
result = (TRUE.equals((String) obj));
} catch (Exception e) {
}
2.注释掉LOCAL_SDK_VERSION := current这个定义:
#LOCAL_SDK_VERSION := current