Search code examples
androidruntimeandroidxandroid-workmanagerandroid.mk

How to implement androidx work runtime in android.mk?


I am trying to add a library into my Android.mk file but I could not succeed yet. There is the implementation of the library in build.gradle file as below;

implementation "androidx.work:work-runtime:2.4.0"

In the Android.mk file I used something like that;

LOCAL_STATIC_ANDROID_LIBRARIES := \
    androidx.work_work-runtime

However it gives an error when I build the project.

error: MyApp (APPS android-arm) missing androidx.work_work-runtime (JAVA_LIBRARIES android-arm) 
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
build/make/core/main.mk:846: error: exiting from previous errors.

So if anyone can help me here I would be so happy. Thanks!!!


Solution

  • Add the definitions below into your makefile..

    LOCAL_STATIC_ANDROID_LIBRARIES := \
      androidx.core_core
    
    LOCAL_STATIC_JAVA_LIBRARIES := \
      androidx.lifecycle_lifecycle-runtime \
      androidx.lifecycle_lifecycle-service \
      androidx.room_room-runtime \
      androidx.sqlite_sqlite \
      androidx.sqlite_sqlite-framework \
      guava \
      workruntime
    
    LOCAL_AAPT_FLAGS := \
      --extra-packages androidx.work
    
    LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := workruntime:libs/work-runtime-2.4.0.aar
    include $(BUILD_MULTI_PREBUILT)