Category Archives: Android

Attach android sources to your applications on eclipse

One of the awesome things about dealing with open software is to be able to access to the source code. When you deal with complex systems (so, every fraking day normally) the worst thing are black boxes that you cannot see, check or change their inside. This black boxes use to be closed/privaty systems/libraries/whatever. Lucky we are, android is open source you can get the source easily with repo but for developing applications in eclipse you can just install Android sources plugin and that’s it, really nice.

http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/

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.

Building Android: error: “_FORTIFY_SOURCE” redefined [-Werror]

If you are building an old version of android probably you’ll have this error

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
:0:0: error: “_FORTIFY_SOURCE” redefined [-Werror]
:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors

To fix this, edit build/core/combo/HOST_linux-x86.mk and replace:

HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0

with

HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

And that’s it.