如何在android.mk中实现androidx工作运行时?

问题描述

我正在尝试将一个库添加到我的Android.mk文件中,但是我还没有成功。 在build.gradle文件中有该库的实现,如下所示;

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

在Android.mk文件中,我使用了类似的内容;

LOCAL_STATIC_ANDROID_LIBRARIES := \
    androidx.work_work-runtime

但是,在构建项目时会出现错误。

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.

所以,如果有人可以在这里帮助我,我会很高兴。谢谢!!!

解决方法

将以下定义添加到您的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)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...