My question concerns using aidl.exe (on a Windows system) from the command line. This question has nothing to do with Eclipse, Netbeans, etc.
Included with the Android SDK are the following three AIDL definition files:
IRemoteService.aidl IRemoteServiceCallback.aidl ISecondary.aidl
located in the following directory:
C:\android-sdk-windows\platforms\android-2.1\samples\ApiDemos\src\com\example\android\apis\app
For the sake of simplicity, I copied aidl.exe into the above directory. Then, from a console Window, I successfully used the following two commands to generate .java files:
C:\Android-project\ApiDemos\src\com\example\android\apis\app>aidl IRemoteServiceCallback.aidl C:\Android-project\ApiDemos\src\com\example\android\apis\app>aidl ISecondary.aidl
Invoking these commands produced the files IRemoteServiceCallback.java and ISecondary.java, respectively. So far so good.
I note that both .aidl files are simple; they include no 'import' statements.
The remaining .aidl file, IRemoteService.aidl, does include the following import statement on line 19:
import com.example.android.apis.app.IRemoteServiceCallback;
The problem arises when I run the AIDL tool on this file:
C:\Android-project\ApiDemos\src\com\example\android\apis\app>aidl IRemoteService.aidl
Doing so causes the following error message to be printed in the console window:
IRemoteService.aidl:19: couldn't find import for class com.example.android.apis.app.IRemoteServiceCallback
The AIDL tool evidently could not locate the IRemoteServiceCallback.aidl file in the same directory in which it was running. According to the AIDL tool's "usage" message, there is a command that apparently can be used to resolve this problem:
-I<DIR> search path for import statements.
The problem: I have not been able to specify -I in such a way as to avoid the error message and have the AIDL tool generate a .java file from the .aidl file with an 'import' statement. (Note: I set the Windows environment variable 'path' to my current directory.) Here are a few variations I've tried:
-Ic:\com\example\android\apis\app
-Ic:/com/example/android/apis/app
-I.\
-I.
I must be missing something simple. Surprisingly, even though I've seen variations of this question posted in various places, I have yet to see an answer or any documentation about AIDL command line usage (other than the aidl.exe USAGE info). Can someone clue me in?
Thanks, Matt
You must provide the folder path to the source files, but WITHOUT the path after the base src folder. So, in your case the right command is:
C:\Android-project\ApiDemos\src\com\example\android\apis\app>aidl -IC:\Android-project\ApiDemos\src\ IRemoteService.aidl