0

Pre-requisites : I am using Android Studio 2.1.2

I have downloaded source of jsoncpp from following link

https://github.com/open-source-parsers/jsoncpp

I have already checked following SO thread , not getting proper solutions :

LOCAL_MODULE_FILENAME should not include file extensions i get this error each time i run ndk-build in terminal

Using JsonCpp on X-Cross platform library

My common Android.mk is as follows:

LOCAL_PATH := $(call my-dir)

#JsonCpp lib

include $(CLEAR_VARS)

LOCAL_MODULE := jsoncpplib

include $(LOCAL_PATH)/jsnlib/Android.mk

LOCAL_STATIC_LIBRARIES := jsnlib

LOCAL_LDLIBS     += -llog -ldl

include $(BUILD_SHARED_LIBRARY)

With code for building some other libraries too , which is working fine.

My jsoncpp's Android.mk is as follows

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/jsnlib/include/json/*.h

FILE_LIST += $(wildcard $(LOCAL_PATH)/jsnlib/src/lib_json/*.cpp)

LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)

LOCAL_MODULE := jsnlib
LOCAL_MODULE_FILENAME:= libjsnlib

include $(BUILD_STATIC_LIBRARY)

When I do ndk-build always getting following error

Android NDK: jni/jsnlib/Android.mk:jsnlib: LOCAL_MODULE_FILENAME should not include file extensions
Android NDK: jni/jsnlib/Android.mk:jsnlib: LOCAL_MODULE_FILENAME must not contain a file extension
Community
  • 1
  • 1
AdiAtAnd
  • 119
  • 1
  • 13
  • Why do you need `LOCAL_MODULE_FILENAME` at all in this case? Seems like you could just remove it. – Michael Sep 01 '16 at 14:52
  • @Michael Tried removing that also, no change , getting same error. One more thing tried with LOCAL_C_INCLUDES := $(LOCAL_PATH)/jsnlib/include/json also, no success. – AdiAtAnd Sep 01 '16 at 14:53
  • Well, you should probably move that `include $(LOCAL_PATH)/jsnlib/Android.mk ` in your main Android.mk so that it's above `include $(CLEAR_VARS)`. – Michael Sep 01 '16 at 14:55
  • Hey thanks a lot for the input. Now I am able to build .so for jsoncpp. Only problem is when I shift this inlcuding for make file above its giving problem while building so's the cpp files I am including above it. This is another issue , I may need to declare separate var for local path then it will get fixed. That's what I think.Can you please put your input in answer? so that I can accept your answer. – AdiAtAnd Sep 01 '16 at 15:21

1 Answers1

1

What happens here is that while you're in the middle of defining your jsoncpplib module you include another makefile, which contains its own module definition:

include $(CLEAR_VARS)
LOCAL_MODULE := jsoncpplib
include $(LOCAL_PATH)/jsnlib/Android.mk
LOCAL_STATIC_LIBRARIES := jsnlib
LOCAL_LDLIBS     += -llog -ldl
include $(BUILD_SHARED_LIBRARY)

You should move the inclusion of the other makefile to above the where you're doing CLEAR_VARS:

include $(LOCAL_PATH)/jsnlib/Android.mk

include $(CLEAR_VARS)
LOCAL_MODULE := jsoncpplib
LOCAL_STATIC_LIBRARIES := jsnlib
LOCAL_LDLIBS     += -llog -ldl
include $(BUILD_SHARED_LIBRARY)

Also, LOCAL_MODULE_FILENAME:= libjsnlib seems redundant, since LOCAL_MODULE := jsnlib should result in the same library name.

Michael
  • 57,169
  • 9
  • 80
  • 125