Reputation: 1821
I have been trying to use IPCs for a multi-apk project.
One of them exposes a Service with quite a few methods. Some of those methods take Parcelable objects as parameters (or returns them).
The first thing I did was to create an aidl file for my Service.
Here's a small part of this aidl file:
package com.test.myapp;
import com.test.mylib.Settings;
interface ISettingsService {
boolean getSettings(in com.test.mylib.Settings arg1);
}
I use Android Studio and gradle, so I saved this aidl file in the src/main/aidl/com/test/myapp/ folder of my module.
As the Settings object is Parcelable, the Android documentation states that I also have to declare an aidl file for it. Note that the Settings class is in another package because it is defined in an included jar library that I cannot modify.
So I created the src/main/aidl/com/test/myapp/Settings.aidl file:
package com.test.mylib;
parcelable Settings;
At build time, the compiler should open my aidl files and generate the proper ISettingsService stub object that I can implement. The problem is that the compiler gives me this error :
error: cannot find symbol
_arg0 = com.test.mylib.Settings.CREATOR.createFromParcel(data);
^
symbol: variable CREATOR
location: class Settings
/.../myapp/build/source/aidl/debug/com/test/myapp/ISettingsService.java:89: error: cannot find symbol
arg1.writeToParcel(_data, 0);
^
symbol: method writeToParcel(Parcel,int)
location: variable arg1 of type Settings
2 errors
:myapp:compileDebugJava FAILED
By reading the error, I suppose that the compiler did not understand that the Settings class was Parcelable.
Do you have any idea of why it doesn't work ? I read numerous articles about that and it seemed pretty clear and easy to do.
Upvotes: 2
Views: 5377
Reputation: 31
I know I am replying to this a little late, I ran into the same issue, others might as well. So I decide to post the resolution that worked for me.
I had to re-define my class such that it implements Parcelable, the link below contains the example I followed. Once all the required methods are defined my code compiled successfully.
http://developer.android.com/reference/android/os/Parcelable.html
Tyler
Upvotes: 3