0

I made a simple project in Android Studio. It compiles with no errors, the editor throws no warnings and the app works fine. BUT if I modify the Android.mk in my project and hit the build button it recompiles everything from scratch. Since it's a small project it takes little time but I can see the wait becoming much longer.

This is my Android.mk:

MY_DIR := $(call my-dir)

LOCAL_PATH := ${MY_DIR}/src/main/cpp
EXTERNAL_PATH := ${MY_DIR}/../..

include $(CLEAR_VARS)
LOCAL_MODULE := cglm
LOCAL_C_INCLUDES := ${EXTERNAL_PATH}/cglm/include
LOCAL_SRC_FILES :=  $(wildcard ${EXTERNAL_PATH}/cglm/src/*.c)

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_SRC_FILES := main.c noop.c renderer.c triangle.c quad.c shaders.c
LOCAL_LDLIBS    := -llog -landroid -lEGL -lGLESv3
LOCAL_STATIC_LIBRARIES := android_native_app_glue

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)

Concrete steps that I took to observe the behaviour I described:
1. With the Android.mk as you see it, I build the app. Everything is compiled from scratch as it should.
2. I change some code inside shaders.c
3. I build the app. Only the shaders.c file is recompiled. Good.
4. I delete shaders.c from the LOCAL_SRC_FILES on Android.mk.
5. I build the app. First thing it does is recompiling the whole cglm module which wasn't even being used by the main module. Then it proceeds to recompile the whole main module as you can see in the Android.mk I showed you.

Why is this happening and can I prevent it from happening without switching to cmake nor using a prebuilt library?

Michael
  • 57,169
  • 9
  • 80
  • 125
  • 1
    See [this old thread](https://groups.google.com/forum/#!topic/android-ndk/0-EliFxMoGA) on the android-ndk mailing list. – Michael Jun 08 '20 at 08:23
  • You are a genius and I love you. Also the only people who answered my questions are called Michael! God bless the Michaels! I never knew searching google forums was a thing, so thanks for that too. – Antonio de las Carreras Jun 09 '20 at 01:06

0 Answers0