Question

I want to compile binder native code which is in c++ i have downloaded native source code for version 4.04.

when i try to build this library it gives me following errors:

    Android NDK: WARNING: APP_PLATFORM android-15 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
   [armeabi] SharedLibrary  : libzzz.so
    D:/android-ndk-r9c-windows-x86/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/zzz/Binder.o: in function android::Vector<android::String16>::do_copy(void*, void const*, unsigned int) const:jni/utils/TypeHelpers.h:142: error: undefined reference to 'android::String16::String16(android::String16 const&)'
    D:/android-ndk-r9c-windows-x86/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/zzz/Binder.o: in function android::Vector<android::String16>::do_splat(void*, void const*, unsigned int) const:jni/utils/TypeHelpers.h:154: error: undefined reference to 'android::String16::String16(android::String16 const&)'
    D:/android-ndk-r9c-windows-x86/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/zzz/Binder.o: in function android::Vector<android::String16>::do_destroy(void*, unsigned int) const:jni/utils/TypeHelpers.h:132: error: undefined reference to 'android::String16::~String16()'

Android.mk

sources := \
Binder.cpp \
BpBinder.cpp \
CursorWindow.cpp \
IInterface.cpp \
IMemory.cpp \
IPCThreadState.cpp \
IPermissionController.cpp \
IServiceManager.cpp \
MemoryDealer.cpp \
MemoryBase.cpp \
MemoryHeapBase.cpp \
MemoryHeapPmem.cpp \
Parcel.cpp \
PermissionCache.cpp \
ProcessState.cpp \
Static.cpp

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE := libbinder1
LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
LOCAL_SRC_FILES := $(sources)
include $(BUILD_SHARED_LIBRARY)

i searched a lot but dint find any help. any help will be really appreciated

Was it helpful?

Solution

delete your previously generated "obj" file from jni and then add android.mk file like below

  LOCAL_PATH := $(call my-dir)

  include $(CLEAR_VARS)
  LOCAL_MODULE    := "your shared library name"// while compile it will be generated as [.so]
 LOCAL_SRC_FILES := \
 Binder.cpp \
 BpBinder.cpp \
 CursorWindow.cpp \
 IInterface.cpp \
 IMemory.cpp \
 IPCThreadState.cpp \
 IPermissionController.cpp \
 IServiceManager.cpp \
 MemoryDealer.cpp \
 MemoryBase.cpp \
 MemoryHeapBase.cpp \
 MemoryHeapPmem.cpp \
 Parcel.cpp \
 PermissionCache.cpp \
 ProcessState.cpp \
 Static.cpp


include $(BUILD_SHARED_LIBRARY)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top