Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: AIDL refusing to generate code from aidl file defining parcelable

Tags:

android

aidl

I am trying to build a library with aidls.

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test

LOCAL_SRC_FILES := $(call all-java-files-under, java) \
java/com/testapp/Istudent.aidl \
java/com/testapp/Itest.aidl \

LOCAL_PREBUILT_JAVA_LIBRARY := framework.jar
include $(BUILD_JAVA_LIBRARY)

I am trying to refer the Istudent in Itest.

Istudent.aidl

package com.testapp;

parcelable Istudent;

Istudent.java

public class Istudent implements Parcelable{}

Itest.aidl

package com.testapp;

import  com.testapp.Istudent;

interface IAP2InterfaceBase {}

But error I receive is E 07-11 20:05:37 71066 71066 aidl.cpp:580] refusing to generate code from aidl file defining parcelable

Kindly let me know what we mean by "refusing to generate code from aidl file defining parcelable" ? And what wrong I am doing here..

like image 556
Aada Avatar asked Jul 11 '17 20:07

Aada


People also ask

What is AIDL file?

An AIDL file is used by Android app developers to enable communication between different apps. It contains Java source code that defines an interface, or contract, for how apps can communicate with each other. AIDL is an implementation of the Interprocess Communication (IPC) protocol provided by Android.

How does AIDL work on Android?

aidl file, the Android SDK tools generate an IBinder interface based on the . aidl file and save it in the project's gen/ directory. The service must implement the IBinder interface as appropriate. The client applications can then bind to the service and call methods from the IBinder to perform IPC.


1 Answers

Reason for Error can be understood as per below source code of aidl:

https://github.com/debian-pkg-android-tools/android-platform-system-tools-aidl/blob/master/aidl.cpp Line:536

if (!interface) {
    LOG(ERROR) << "refusing to generate code from aidl file defining "
                  "parcelable";
    return AidlError::FOUND_PARCELABLE;
  }

Also the aidl file that declares your parcelable class is not supposed to be included in build as mentioned on https://developer.android.com/guide/components/aidl.html under 'Passing Objects over IPC'. Below snippet copied from the website.

Finally, create an .aidl file that declares your parcelable class (as shown for the Rect.aidl file, below). If you are using a custom build process, do not add the .aidl file to your build. Similar to a header file in the C language, this .aidl file isn't compiled.

like image 141
optimus Avatar answered Sep 19 '22 12:09

optimus