8

I have defined an AIDL android interface to make available a service from other applications.

My problem is that in my project, Android does not generate the Java file from this AIDL. Note that the project compiles and works fine. However, if I move this AIDL file to another project, Android generates the Java file.

I don't know where I can debug this kind of error or where I can read some log about this.

Can anybody help me?

pablo.mj
  • 121
  • 1
  • 1
  • 6
  • I define only one class, and eclipse says: syntax error before ';' (expected method declaration) `public void placeCall(String accountID, in String callID, in String to);` – m-ric Sep 21 '12 at 18:29

6 Answers6

10

I met the same issue and work fine for me on Android Studio. There are two ways to fix this.

Method 1:

Put AIDL files under src/main/aidl package to follow default source setting for gradle build.

It is easy way but not be smart.

Method 2:

  1. Keep aidl files under your custom package.

  2. Add source setting mapping in build.gradle file as below

    sourceSets {
       main {
         aidl.srcDirs = ['src/main/java']
       }
    }
    

Don't forget clean and rebuild after setting as above.

More information please refer this,

https://issuetracker.google.com/issues/36972230

https://issuetracker.google.com/issues/36972230

https://issuetracker.google.com/issues/36988483

Luna Kong
  • 3,065
  • 25
  • 20
6

I ran into a similar issue. Using Android Studio, the file is required to be in a specific location unless you override it in Gradle.

I had to put the aidl file in 'src/main/aidl/example/package/name/' <-- The declared package in the aidl file would be 'package example.package.name'.

It requires the file to be in a specific aidl folder and to have a folder structure that matches the package name declared in the aidl. I found the initial hint here: https://code.google.com/p/android/issues/detail?id=56328

bduhbya
  • 410
  • 5
  • 6
5

Eclipse displays you the errors directly in the .aidl file, so check your file first. I got similar issue, and found my problem: I prefixed my interface functions with public. That was wrong. For instance:

package com.example.phone.service;

interface IService {
    public void placeCall(String a, in String b, in String c);
}

should be:

package com.example.phone.service;

interface IService {
    void placeCall(String a, in String b, in String c);
}

Don't forget the .java generated file is located in gen/ not src/.

m-ric
  • 5,621
  • 7
  • 38
  • 51
1

Try cleaning the project, that's often helping to resolve those types of errors. Also check that it does not contain errors since errors can prevent completion of some compile steps.

Assuming you use Eclipse have a look at the "Console" view (Window > Show View > Console) which should contain the output of the compile process.

zapl
  • 63,179
  • 10
  • 123
  • 154
  • Yes. I'm using Eclipse. The provided feedback of the Console is OK. It doen's tell me nothing about the aidl transformation. – pablo.mj Sep 21 '12 at 10:03
  • Hmm, if there is no error then the build process does not pick up the aidl file. Maybe it is in the wrong place or you have somehow messed up the configuration of the project. Rightclick project in explorer > Android Tools > Fix Project Properties - could help. If you don't get it to work you could also create a new project based on the one that doesn't work. – zapl Sep 21 '12 at 10:11
  • Hi, I tried all the things but anything solved the problem. I installed another Eclipse, Android SDK, and the files were generated. – pablo.mj Oct 10 '12 at 14:52
1

if you go to one of the parent directories depending on where you trying to create the interface e.g framework/base/ you will find the make file of this dir called Android.mk in this file you should add the .aidl name in the proper spots (it is easy to understand exactly where thanks to the comments) and then build. the "your interface".java will be generated.

1

If using AGP 8

buildFeatures {
    aidl = true
}

https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes#default-changes