Android studio externalNativeBuild - problem with debugging external c file (path containing ".." (upper directory))

54 views
Skip to first unread message

Miro Almy

unread,
Nov 7, 2016, 2:47:37 PM11/7/16
to android-ndk
Typical Android.mk looks like:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := module_name
LOCAL_SRC_FILES := \
$(LOCAL_PATH)/file1.c\
$(LOCAL_PATH)/../file2.c

include $(BUILD_SHARED_LIBRARY)



My problem:
Android Studio can't debug file2.c whose path in Android.mk contain ".."
Files without ".." in their paths is debuggable without any problems.


Example:
c:/dirA/dirB/Android.mk
c:/dirA/dirB/file1.c
c:/dirA/file2.c

LOCAL_SRC_FILES :=
file1.c # no technical problem
LOCAL_SRC_FILES := $(LOCAL_PATH)/file1.c # no technical problem
LOCAL_SRC_FILES := C:\\dirA\\dirB\\file1.c # no technical problem

LOCAL_SRC_FILES :=
../file2.c # can compile file, but can't debug file!
LOCAL_SRC_FILES := $(LOCAL_PATH)/../file2.c # can compile file, but can't debug file!
LOCAL_SRC_FILES := C:\\dirA\\dirB\\..\\file2.c # can compile file, but can't debug file!

LOCAL_SRC_FILES := C:\\dirA\\file2.c # no technical problem, but unusable in big project

Alex Cohn

unread,
Nov 24, 2016, 10:02:33 AM11/24/16
to android-ndk
Android Studio can't debug file2.c whose path in Android.mk contain ".."

This is probably because ndk-build uses __ (double underscore) character to express the path for compiled files to ../, but the debugger is not smart enough to reverse this mapping.

The easy workaround is to set

LOCAL_PATH := $(call my-dir)/..

(or whatever path high enough in file system), and tune the Android.mk appropriately.

Cheers,
Alex
Reply all
Reply to author
Forward
0 new messages