Trying to install a simple app that uses the Android Room to build a database, as a system app in AOSP. Stuck at what to include in the Android.mk makefile.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under,src)
LOCAL_RESOURCE_DIR := /home/<username>/WORKING_DIRECTORY/packages/apps/appname/res
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_MODULE_TAGS := optional
LOCAL_USE_AAPT2 := true
LOCAL_STATIC_JAVA_LIBRARIES := \
android-common
LOCAL_STATIC_ANDROID_LIBRARIES := \
androidx.annotation_annotation \
androidx.legacy_legacy-support-core-ui \
androidx.appcompat_appcompat \
androidx.core_core \
androidx.recyclerview_recyclerview \
androidx.room_room-common \
androidx.room_room-migration \
androidx.room_room-runtime \
androidx.room_room-testing \
android-support-annotations \
androidx.cursoradapter_cursoradapter \
androidx.sqlite_sqlite \
androidx.sqlite_sqlite-framework \
androidx.lifecycle_lifecycle-common \
androidx.lifecycle_lifecycle-common-java8 \
androidx.lifecycle_lifecycle-runtime \
androidx.lifecycle_lifecycle-service
LOCAL_ANNOTATION_PROCESSOR_CLASSES := \
androidx.room.RoomProcessor
LOCAL_PACKAGE_NAME := com.app.appname
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
include $(BUILD_PACKAGE)
However, upon running the emulator after "make -j4" it gives the error -
E AndroidRuntime: java.lang.RuntimeException: cannot find implementation for com.app.appname.RoleManagerDB. RoleManagerDB_Impl does not exist
E AndroidRuntime: at com.app.appname.RoleManagerDB.getDatabase(RoleManagerDB.java:27) E AndroidRuntime: at com.app.appname.MainActivity.lambda$onCreate$0$MainActivity(MainActivity.java:28)
E AndroidRuntime: at com.app.appname.-$$Lambda$MainActivity$xxx.run(Unknown Source:4) W ActivityTaskManager: Force finishing activity com.app.appname/.MainActivity
My app compiles and runs smoothly on Android Studio, so what am I missing in the makefile?
My guess is I cannot seem to translate the gradle line:
annotationProcessor "androidx.room:room-compiler:$room_version"
to its makefile equivalent. Any help is much appreciated!
I had a lot of trouble finding information about this too.
The Android 10 Bluetooth Application uses Room, and the AnnotationProcessor is configured in its makefile (https://cs.android.com/android/platform/superproject/+/android-10.0.0_r30:packages/apps/Bluetooth/Android.mk)
In my module, I added:
include $(CLEAR_VARS)
...
LOCAL_ANNOTATION_PROCESSORS := annotation
LOCAL_ANNOTATION_PROCESSORS += room-common
LOCAL_ANNOTATION_PROCESSORS += room-compiler
LOCAL_ANNOTATION_PROCESSORS += room-migration
LOCAL_ANNOTATION_PROCESSORS += s-antlr4 # a later version of antlr4 is already on the classpath, be we want this version
LOCAL_ANNOTATION_PROCESSORS += apache-commons-codec
LOCAL_ANNOTATION_PROCESSORS += auto-common
LOCAL_ANNOTATION_PROCESSORS += s-javapoet #the name javapoet is already defined - prefix for uniqueness
LOCAL_ANNOTATION_PROCESSORS += kotlin-metadata
LOCAL_ANNOTATION_PROCESSORS += sqlite-jdbc
LOCAL_ANNOTATION_PROCESSORS += jetbrain-annotations
LOCAL_ANNOTATION_PROCESSORS += guava-21.0
LOCAL_ANNOTATION_PROCESSORS += kotlin-stdlib
LOCAL_ANNOTATION_PROCESSOR_CLASSES := androidx.room.RoomProcessor
...
include $(BUILD_PACKAGE)
I also added a new module:
#These libraries get copied into out/host/common/obj/JAVA_LIBRARIES/
# and are required for annotation processing
include $(CLEAR_VARS)
LOCAL_LIBS_PATH := libs
COMMON_LIBS_PATH := ../../../prebuilts/tools/common/m2/repository
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
annotation:$(LOCAL_LIBS_PATH)/annotation-1.0.0-beta01.jar \
room-common:$(LOCAL_LIBS_PATH)/room-common-2.0.0-beta01.jar \
room-compiler:$(LOCAL_LIBS_PATH)/room-compiler-2.0.0-beta01.jar \
room-migration:$(LOCAL_LIBS_PATH)/room-migration-2.0.0-beta01.jar \
s-antlr4:$(COMMON_LIBS_PATH)/org/antlr/antlr4/4.5.3/antlr4-4.5.3.jar \
apache-commons-codec:$(COMMON_LIBS_PATH)/org/eclipse/tycho/tycho-bundles-external/0.18.1/eclipse/plugins/org.apache.commons.codec_1.4.0.v201209201156.jar \
auto-common:$(COMMON_LIBS_PATH)/com/google/auto/auto-common/0.9/auto-common-0.9.jar \
s-javapoet:$(COMMON_LIBS_PATH)/com/squareup/javapoet/1.8.0/javapoet-1.8.0.jar \
jetbrain-annotations:$(COMMON_LIBS_PATH)/org/jetbrains/annotations/13.0/annotations-13.0.jar \
kotlin-metadata:$(COMMON_LIBS_PATH)/me/eugeniomarletti/kotlin-metadata/1.2.1/kotlin-metadata-1.2.1.jar \
sqlite-jdbc:$(COMMON_LIBS_PATH)/org/xerial/sqlite-jdbc/3.20.1/sqlite-jdbc-3.20.1.jar
include $(BUILD_HOST_PREBUILT)
I stuck with the library versions that were used by Bluetooth on my device - I experienced dependency conflicts once I started upgrading libraries.