Search code examples
android-ndkparcelableaidl

How do I define a custom class with Parcelable using Stable AIDL?


With the introduction of Stable AIDL, defined parcelables are required to be structured (Parcelables with their fields defined in AIDL are called structured parcelables). https://source.android.com/docs/core/architecture/aidl/stable-aidl

For instance, earlier we could define a custom header and implementation by providing an AIDL file that points to the header for your custom object using the cpp_header directive. This is not allowed with Stable AIDL.

How do I make the similar with Stable AIDL?

Basically this is what I try to achieve but with Stable AIDL. AIDL interface between Java and C++


Solution

  • Basically what I want to achieve will be introduced in Android 14 for AIDL NDK backend.

    https://source.android.com/docs/core/architecture/aidl/aidl-annotations#ndkonlystableparcelable

    https://source.android.com/docs/core/architecture/aidl/stable-aidl#defining-an-aidl-interface