I am an Android Firmware developer, working with a source of Android 12. I am facing an issue while I try to build a system application called ServiceMode. I am trying to build this application along with Android build and move it to system partition.
I get the below build error in Android.mk definition written by me: "Specifies both LOCAL_SDK_VERSION (system_current) and LOCAL_PRIVATE_PLATFORM_APIS (true) but should specify only one"
In my makefile I have mentioned only LOCAL_PRIVATE_PLATFORM_APIS := true, since I am using hidden APIs and I haven't mentioned LOCAL_SDK_VERSION. But still I am getting a build error stating that both LOCAL_SDK_VERSION and LOCAL_PRIVATE_PLATFORM_APIS are mentioned in Android.mk
My Android.mk file looks like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES += $(call all-java-files-under, java/com/foo/example/servicemode)
LOCAL_SRC_FILES += $(call all-java-files-under, java/com/bar)
ifeq "$(LOCAL_REGION)" "JP"
LOCAL_MANIFEST_FILE := java/com/foo/example/servicemodejp/AndroidManifest.xml
LOCAL_SRC_FILES += $(call all-java-files-under, java/com/foo/example/servicemodejp)
endif
ifeq "$(PROJECT_SERIES)_$(LOCAL_REGION)" "US"
LOCAL_MANIFEST_FILE := java/com/foo/example/servicemodeus/AndroidManifest.xml
LOCAL_SRC_FILES += $(call all-java-files-under, java/com/foo/example/servicemodeus)
endif
LOCAL_PACKAGE_NAME := ServiceMode
LOCAL_CERTIFICATE := platform
LOCAL_ODM_MODULE := true
LOCAL_JAVA_LIBRARIES := com.bar.twoworlds.mobile\
com.foo.example.mobileinput.provider.util \
ifeq "$(LOCAL_REGION)" "JP"
LOCAL_JAVA_LIBRARIES += com.foo.example.jp
endif
LOCAL_STATIC_JAVA_LIBRARIES := \
com.foo.example.osdplanevisibilitymanager \
com.foo.example.provider.modelvariation.util \
com.foo.example.hardware.display-V1.0-java\
android-support-annotations
ifeq "$(PROJECT_SERIES)_$(LOCAL_REGION)" "US"
LOCAL_STATIC_JAVA_LIBRARIES += com.foo.example.mobileapi
endif
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_DEX_PREOPT := false
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
com.foo.example.osdplanevisibilitymanager:libs/com.foo.example.osdplanevisibilitymanager.jar
ifeq "$(PROJECT_SERIES)_$(LOCAL_REGION)" "US"
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += com.foo.example.mobileapi:libs/mobileapi-1.13.0.jar
endif
include $(BUILD_MULTI_PREBUILT)
Apps in vendor/odm/product partitions are not allowd to use private api.
The rule is enforced to make sure that the system img(Android Framework) can be upgraded while the other img are not upgraded.
You have set LOCAL_ODM_MODULE to true, which will caused that LOCAL_SDK_VERSION are set as system_current. Then the error message will be shown.