Building Android: error: passing ‘const android::RefBase::weakref_impl’

If you are building android in ubuntu >10.04 you are gonna get this awesome error:

:0:0: warning: “_FORTIFY_SOURCE” redefined [enabled by default]
:0:0: note: this is the location of the previous definition
frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:
frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] Error 1

Like the error itself tell us, the fix is to add the flag fpermissive, so let’s edit frameworks/base/libs/utils/Android.mk and change:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

to

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

And let the compiler do its job.

Comments are closed.

Post Navigation