Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AIDL file does not generated a Java file

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?

like image 977
pablo.mj Avatar asked Sep 21 '12 09:09

pablo.mj


3 Answers

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

like image 147
Luna Kong Avatar answered Sep 30 '22 11:09

Luna Kong


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

like image 22
bduhbya Avatar answered Sep 30 '22 12:09

bduhbya


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/.

like image 33
m-ric Avatar answered Sep 30 '22 12:09

m-ric