Working with android: aidl & “couldn’t find import for class”


In a recent project, I found myself attempting to create a service interface.

I followed along with googles documentation, but ran into problems as soon as I tried to use my own Parcel objects.
I had implemented  the Parcelable interface in my class.

package com.fauxgrammer.model;

import android.os.Parcel;
import android.os.Parcelable;

public class Player implements Parcelable {

private String username;
private String password;

public static final Parcelable.Creator<Player> CREATOR = new Parcelable.Creator<Player>() {

public Player createFromParcel(Parcel in) {
    return new Player(in);

public Player[] newArray(int size) {
    return null;


public Player() {

private Player(Parcel in) {

public int describeContents() {
    return 0;

public void writeToParcel(Parcel out, int flags) {
public void readFromParcel(Parcel in) {
    username = in.readString();
    password = in.readString();


Then created my own interface file for my service.

/* interface.aidl */
package com.fauxgrammer.service;

import package com.fauxgrammer.model.Player;

interface FauxService {
void login (inout Player user);

This all seemed correct, but eclipse reported “couldn’t find import for class com.fauxgrammer.model.Player”

I was stumped, couldn’t work out what was going on.
I googled around on the subject(knee-jerk), but i couldn’t find a solution.

After much furrowing of my brow, I found the answer. where else? In google’s documentation. As usual, they were vague on how to use Parcel objects (to me at least).
You must create a separate .aidl file for each class you wish to use within your service that declares that class as parcelable.

so in our example, we need to add Player.aidl to com.fauxgrammer.model

package com.fauxgrammer.model;

parcelable Player;

I cleaned my project, and the error was gone. Celebrate!

ok, it seems simple now, but it hung me up for a second.

There are 10 comments in this article:

  1. 22/09/2010MMan says:

    I had the same problem and tried many workarounds that I googled but they did not work for the lastest SDK.
    This post finally solved my problems. Thanks!
    Vague documentation from Goole is an understatement, it kind of sucks…

  2. 8/10/2010Peter says:

    This is great! Thanks a lot!!!!

  3. 20/10/2010peg says:

    thanks dude!

  4. 22/08/2011Cata says:

    Thanks, you have been a great help!

  5. 10/10/2011Julia says:

    I had the same problem too. You solved it, thanks!!!!!

  6. 14/02/2012Nithin says:

    Nice Fauxgrammer..I was Bugged with this Error..Thanks

  7. 11/04/2012Michael says:

    You made my day, man!

  8. 18/04/2012tobi says:

    thanks man!

  9. 3/07/2012markus says:

    THX. This solved my problem ;-)

  10. 20/09/2013Sergey says:

    Thanks. I spent 1 hour attempting to solve this problem.

Write a comment: