I have a project that uses AIDL interfaces and everything is building just fine in android studio with gradle. however, im only using android studio for the convenience of an IDE for developing my android applications, i have to actually use Android make files to build my applications with the rest of the AOSP tree.
when i started this project i just had one small aidl file as a proof of concept and it built fine in both AS and android make. but when i started adding more aidl files it just broke with the error:
[ 14% 1/7] Aidl: myradioservice<= vendor/apps/radioservice/myRadioService/aidl/com/foo/myradioservice/IMetadataCallback.aidl
FAILED: out/target/common/obj/APPS/myRadioService_intermediates/aidl/com/foo/myradioservice/IMetadataCallback.java
vendor/apps/radioservice/myRadioService/aidl/com/foo/myradioservice/IMetadataCallback.aidl:4: couldn't find import for class com.foo.myradioservice.MyMetaData
[ 28% 2/7] Aidl: myradioservice <= vendor/apps/radioservice/myRadioService/foo/com/foo/myradioservice/IMyRadioManager.aidl
FAILED: out/target/common/obj/APPS/myRadioService_intermediates/aidl/com/harman/myradioservice/IMyRadioManager.java
vendor/apps/radioservice/myRadioService/aidl/com/foo/myradioservice/IMyRadioManager.aidl:4: couldn't find import for class com.foo.myradioservice.IMetadataCallback
here are my aidl files:
IMetadataCallback.aidl
package com.foo.myradioservice;
import com.foo.myradioservice.MyMetaData;
interface IMetadataCallback {
void onMetadataChange(out MyMetaData metadata);
}
IMyManager.aidl
package com.foo.myradioservice;
import com.foo.myradioservice.IMetadataCallback;
interface IMyManager {
void tune(int channelNumber);
void registerMetadataListener(IMetadataCallback cb);
void unregisterMetadataListener(IMetadataCallback cb);
}
MyMetadata.aidl
package com.foo.myradioservice;
parcelable MyMetaData;
(I also have a MyMetadata.java file that implements Parcelable in the java source directory.)
and here is my android make file
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := myRadioService
LOCAL_AIDL_INCLUDES := $(call all-Iaidl-files-under, aidl)
LOCAL_SRC_FILES := $(call all-java-files-under, java) $(call all-Iaidl-files-under, aidl)
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR += frameworks/support/v7/appcompat/res
LOCAL_JAVA_LIBRARIES := android.car
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
include $(BUILD_PACKAGE)
Things ive tried:
- moving all aidl files into the java directory with the rest of the code, ive seen this done in other places.
- creating a separate module that compiles the aidl files and including that into my service, also have seen this done in other places.
- moving the parcelable java code into the aidl directory
- stubbing out all implementations of the interfaces
- changing my aidl includes macro to: LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/aidl as suggested in another SO answer
- all sorts of combinations of changes to the LOCAL_SRC_FILES and LOCAL_AIDL_INCLUDES, even using absolute paths to the files