Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Aidl Compile Error: couldn't find import for class

Tags:

android

aidl

(I know there're multiple questions on stackoverflow and elsewhere (like google group) about adding parcelable for NetworkInfo but this is not about that.)

My work is under $(AOSP_ROOT)/device/ and involves multiple aidl files. one of it is like,

package com.example;

parcelable SomeRequest;

And another aidl is like,

package com.example;

import com.example.SomeRequest;
interface SomeService {
    SomeRequest getRequest();
}

And I'll get compile errors like,

device/somedevice/sdk/libs/aidl/com/example/SomeService.aidl:9: couldn't find import for class com.example.SomeRequest

I'm wondering it is the order of processing aidl files. My Android.mk looks like,

LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-under, aidl)
LOCAL_AIDL_INCLUDES := $(call all-Iaidl-files-under, aidl)

This build error is introduced after I moved aidl files from src/ folder to aidl/ folder (for some reason I have to do so). It worked before but now even if I moved it back to src/ folder it doesn't work anymore. I tried to clean up $(AOSP_ROOT)/out/device/target but it's not helping.

Ideas?

like image 889
Chundong Wang Avatar asked Nov 25 '14 23:11

Chundong Wang


1 Answers

Finally I got it resolved.

If you dig into /build/core/base_rules.mk, you'll find that LOCAL_AIDL_INCLUDES is actually the folders to be included during AIDL compiling phase in addition to the default folders like framework or so.

$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))

In this specific case, what you want is actually,

LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-under, aidl)
LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/aidl
like image 176
Chundong Wang Avatar answered Sep 22 '22 10:09

Chundong Wang