I am an android firmware developer. I work with source of android 9. I've written a custom network location provider for AOSP firmware, named offline location service. I've added this application to packages/apps/offlinelocatonservice
path in AOSP build tree.
I've created an Android.mk
file for it to include it in default packages in android OS.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := OfflineLocationService
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_CERTIFICATE := platform
LOCAL_USE_AAPT2 := true
# Include libraries
LOCAL_JAVA_LIBRARIES := framework com.android.location.provider
LOCAL_STATIC_JAVA_LIBRARIES := android-common
LOCAL_STATIC_ANDROID_LIBRARIES := \
android-support-v4 \
android-support-v7-appcompat \
android-support-design \
android-support-v7-preference \
android-support-v7-recyclerview \
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat
LOCAL_AAPT_FLAGS += --extra-packages android.support.design
include $(BUILD_PACKAGE)
But when I build AOSP, I encounter with this error:
packages/apps/OfflineLocationService/Android.mk: error: OfflineLocationService (java:sdk) should not link to com.android.location.provider (java:platform)
packages/apps/OfflineLocationService/Android.mk: error: OfflineLocationService (java:sdk) should not link to framework (java:platform)
Why I should not link to com.android.location.provider
and framework
?
In previous androids such as android 8 and earlier, this error doesn't happen.
How can I solve this error?
I have the same problem in Android 9.0
Temporary I solved by changing OfflineLocationService/Android.mk
replacing:
LOCAL_SDK_VERSION := current
with:
LOCAL_PRIVATE_PLATFORM_APIS := true
But it would be nice if anyone could find a better solution.