Android ndk nested modules

I have a native project that in frustration with the make system I got working by simply jamming all the code together many years ago. I attempted to port the project properly to gradle-experimental, but that’s still a disaster 2.5 years later. I’m now trying to get the system to work within the reorganized (for gradle-experimental) project.

Here’s the organization:

  • Draw a perfect curve connecting three points
  • Programatically logging in from WebView
  • Loading tall images from url in slivers preventing whole image from loading into ram
  • Android Studio: Android Manifest doesn't exists or has incorrect root tag
  • AppWidgetManager getAppWidgetIds returning old Widget ids
  • Calculate image size when using setCompoundDrawables for EditText
    • jpeg (full native)
    • processor (full native, dependent on jpeg)
    • library (jni, dependent on processor and jpeg)

    -jni (contains,
    ----jni (and source co-located)
    -----jni (and source co-located)

    I know I could flatten this if I use the make files, but I figure someday in 2020 Android Studio will truly support native so I figured I’d keep the current project format.

    Here are my make files:


    LOCAL_PATH := $(call my-dir)
    include $(STARTUP_DIR)/../jpeg/src/main/jni/
    include $(STARTUP_DIR)/../processor/src/main/jni/
    include $(STARTUP_DIR)/../library/src/main/jni/
    include $(CLEAR_VARS)


    LOCAL_PATH:= $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_ARM_MODE := arm
    LOCAL_SRC_FILES := [truncated]
    LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays
    #LOCAL_CFLAGS += -march=armv6j
    # enable tile based decode
    ifeq ($(TARGET_ARCH_VARIANT),x86-atom)
      LOCAL_SRC_FILES += jidctintelsse.c
    # enable armv6 idct assembly
    ifeq ($(strip $(TARGET_ARCH)),arm)
    # use mips assembler IDCT implementation if MIPS DSP-ASE is present
    ifeq ($(strip $(TARGET_ARCH)),mips)
      ifeq ($(strip $(ARCH_MIPS_HAS_DSP)),true)
      LOCAL_SRC_FILES += \
          mips_jidctfst.c \
    LOCAL_MODULE := libjpeg


    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../jpeg/src/main/jni
    LOCAL_MODULE     := processor
    LOCAL_SRC_FILES := [truncated]
    LOCAL_C_INCLUDES += [truncated]
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/processor/include
    LOCAL_LDLIBS += -lz

    When I run ndk-build it will successfully build jpeg when it gets to the processor build. It will however fail to build any code referencing jpeg (in processor) with undefined references such as:

    undefined reference to `jpeg_std_error(jpeg_error_mgr*)’

    I have a feeling I’m doing something slightly wrong in setting up the parent such that LOCAL_STATIC_LIBRARIES += libjpeg is not correctly importing. Anyone know what I might be doing wrong here?

    Related posts:

    Is it possible to Install Android Studio on ChromeBook?
    Default Navigation Drawer View to ExpandableListView
    Java simple Timestamp to Date conversion
    Retrofit and Centralized Error Handling
    How can I programmatically display a ViewFlipper's second child?
    How to Add Click event in Stack Layout or Frame
  • Facebook Access Token always null
  • onContextItemSelected does not get called in a DialogFragment
  • Android Paint: .measureText() vs .getTextBounds()
  • How to use local aar dependency?
  • Are Android LDPI assets/icons still needed?
  • Intent.ACTION_PICK returns empty cursor for some contacts
  • One Solution collect form web for “Android ndk nested modules”

    Turns out I pulled the wrong jpeg header which didn’t have extern “C” to help with name mangling in c++. Fixing the header addressed the issue.

    Additionally, I had to reorganize the folder structure as nested NDK is a nightmare if all projects don’t fall under jni. It will start mangling LOCAL_PATH, wildcards, and basically any relative path.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.