4

In the spirit of re-using code, I'm trying to create a few library projects. However, I seem to run into a problem defining .aidl files that span the libraries. Here is the problem:

In library A I have Foo.java and Foo.aidl. Foo.java is Parcelable so the aidl declaration is:

Foo.aidl:

package com.example.library.A;
parcelable Foo;

Now I'm trying to create library B. In library B I want to define a service interface that uses class Foo:

IMyService.aidl:

package com.example.library.B;
import com.example.library.A.Foo;

interface IMyService {
    void requestSomething(in Foo fooBug);
}

This file does not compile complaining that it couldn't find the import for Foo. I've tried referencing library A and I've tried adding the library project as an external jar, but neither work.

Is there a limitation that I don't know about? Am I doing something wrong with my project setup??

I should probably mention that I've used library A directly in a project with no problem so I'm confident that lib A is not the problem.

Goofy
  • 6,098
  • 17
  • 90
  • 156
jsmith
  • 4,847
  • 2
  • 32
  • 39
  • This works fine for me - both using a library's AIDL classes in a non-library project, and in another library. Your Eclipse projects should have an item 'Library Projects' in their trees. Ensure that B's entry contains a reference to the expected JAR of A. – Rob Pridham Feb 14 '12 at 14:36
  • I recall it working for me with some prototypes I wrote a while back. But it doesn't now. I suspect updating to the v14 of the tools broke it: http://tools.android.com/recent/buildchangesinrevision14 – jsmith Feb 14 '12 at 15:57
  • 1
    I have it working, but I'm not happy with the solution. In lib B, I had to add the com.example.library.A package and copy the Foo.aidl file into it. – jsmith Feb 14 '12 at 15:59

1 Answers1

2

I have it working, but I'm not happy with the solution. In lib B, I had to add a com.example.library.A package and copy the Foo.aidl file into it.

jsmith
  • 4,847
  • 2
  • 32
  • 39
  • Didn't this cause issues when running an app that uses lib B? I'm getting `Duplicate class ... found in modules ... (lib A) and ... (lib B)` errors. – Guilherme Santos Jul 22 '21 at 12:09