2015年3月12日 星期四
KK上編譯property_get/set 產生的編譯錯誤
KK上使用
property_get/property_set出現編譯錯誤
system/core/include/cutils/properties.h:22:35: fatal error: sys/system_properties.h: No such file or directory compilation terminated. 在Android 4.2以前不會發生此問題
當使用 property_get 、 property_set 、 system_properties.h 發生編譯錯誤
<解決方式>
從Android 4.4後,Google規定libcutils不在Support host side的property,只Support taget side的property,所以做host build請不要include property.h或者對property進行操作。
修改方法
1. 修改该module的Android.mk, 在host build部分加入以下設定:
include $(CLEAR_VARS)
... ...
LOCAL_CPPFLAGS += -D XX_HOST_BUILD
include $(BUILD_HOST_STATIC_LIBRARY)
2. 修改该module的cpp文件,将關聯到的Property的内容全部用XX_HOST_BUILD包起来,如下:
#ifndef XX_HOST_BUILD
#include <cutils/properties.h>
#endif
#ifndef XX_HOST_BUILD
property_get()
#endif
#ifndef XX_HOST_BUILD
property_set()
#endif
以上文章轉自
http://www.jiquan123.com/index.php?m=3g&c=read&tid=3310&fid=10
訂閱:
張貼留言 (Atom)
大大知道 host build 找不到 sys/system_properties.h 的這個規則寫在哪裡嗎?找了一陣子找不到!如果大大有找到的話再幫忙提示一下!!感謝~~
回覆刪除