A simple way to build with the Android NDK

Viewed 858

I started out writing a simple C++ program that tried to get the handle of a service using

defaultServiceManager()->getService(String16('ServiceName'));

Which has now snowballed into this terrible dependency recursion. Ultimately what I need is:

  • libbinder for defaultServiceManager and getService
  • libutils for String16

Neither of these are available in the NDK. Their sources are in the SDK along with all the appropriate headers. I can get everything to behave nicely until link time:

undefined reference to `android::defaultServiceManager()'
undefined reference to `android::String16::String16(char const*)'
undefined reference to `android::String16::~String16()'
undefined reference to `android::String16::~String16()'

Is it required to build this as a part of AOSP? Perhaps through something like ndk-build? What I am building is more of a toy application that only needs access to those (and related, e.g. service->transact APIs) APIs along with Parcel.

Perhaps building AOSP once and using -L to include a search path to the generated libs.

1 Answers
Related