Archive of articles classified as' "Android"

Back home

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.