Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AIDL not finding inner classes

Tags:

android

aidl

Trying to compile AIDL files found in the Android repo along with my Android project to use some of the built-in interfaces.

However, whenever I get to an inner type, I get the following error:

ITuner.aidl

aidl E 01-12 17:32:41 59280 1006000 type_namespace.cpp:129] In file ./app/src/main/aidl/android/hardware/radio/ITuner.aidl line 32 parameter config (argument 1):
aidl E 01-12 17:32:41 59280 1006000 type_namespace.cpp:129]     unknown type
aidl E 01-12 17:32:41 59280 1006000 type_namespace.cpp:107] In file ./app/src/main/aidl/android/hardware/radio/ITuner.aidl line 34 return type RadioManager.BandConfig:
aidl E 01-12 17:32:41 59280 1006000 type_namespace.cpp:107]     unknown type
aidl E 01-12 17:32:41 59280 1006000 type_namespace.cpp:107] In file ./app/src/main/aidl/android/hardware/radio/ITuner.aidl line 66 return type RadioManager.ProgramInfo:
aidl E 01-12 17:32:41 59280 1006000 type_namespace.cpp:107]     unknown type
aidl E 01-12 17:32:41 59280 1006000 type_namespace.cpp:107] In file ./app/src/main/aidl/android/hardware/radio/ITuner.aidl line 83 return type List<RadioManager.ProgramInfo>:
aidl E 01-12 17:32:41 59280 1006000 type_namespace.cpp:107]     unknown type

This happens for all inner types. What am I doing wrong?

Other things:

  • I copied all of the AIDL files in my project in the correct directory structures
  • All of the AIDL files build except the ones with inner classes. Inner classes give unknown type errors.
  • I am using the AIDL executable in the API 27 platform directory.
like image 560
Jason Avatar asked Jan 12 '18 22:01

Jason


1 Answers

These AIDL files and their backing services/classes are hidden from the public API, meaning they are not stable/consistent for all versions of Android. You will not be able to directly use them in your code to access built-in services of the system. You'd have to rely on reflection to gain access to other hidden classes in order to then get access to the underlying binder object of the system provided service. Not a portable or easy solution. If you are trying to re-create the system services within your app and your app will only use your version, then it will make sense to pull these files into your app.

All of that being said, if you are trying to create these services are part of your app, there's more than just the AIDL needed. The AIDL defines the interface a service implements, which in turn generates some Java boilerplate code for you. The missing dependencies you are seeing are because those are not other service interfaces, but classes which are Parcelable, allowing them to be passed as arguments or returned from binder IPC methods. As an example, the missing dependency for RadioManager.BandConfig is an inner class defined in RadioManager.java. You would need this class in your project as well.

like image 93
Larry Schiefer Avatar answered Sep 30 '22 02:09

Larry Schiefer