19

I have found a sample from the Internet (https://github.com/manishkpr/Android-AIDL-Example) and ran on Android Studio and it worked fine.

But now when I am trying to recreate the project, the Android Studio fails to recognize the .aidl file no matter where I place it. Can anybody tell me what is the right location to place .aidl files in Android Studio?

p.s. I have added the below code to build.gradle and place the .aidl file in the java directory, but failed to get it work.

sourceSets {
main {
    aidl.srcDirs = ['src/main/java']
}
Code_Yoga
  • 2,968
  • 6
  • 30
  • 49

5 Answers5

16

The below link solved my issue.

https://code.google.com/p/android/issues/detail?id=56160

pRaNaY
  • 24,642
  • 24
  • 96
  • 146
Code_Yoga
  • 2,968
  • 6
  • 30
  • 49
16

In my case Clean and Rebuild project solved my problem.
Hope this helpful.

Naruto Uzumaki
  • 2,019
  • 18
  • 37
6

The default Android project sourceSet has a definition that looks for .aidl files under "src/main/aidl". Moving my aidl files there solved the problem.

https://code.google.com/p/android/issues/detail?id=56328

SurlyDre
  • 463
  • 5
  • 5
  • This link helped me because I was not seeing the gen folder showing aidl being generated by the build. The link (#2) mentions that it can also appear in build/generated/source/aidl (their path was writen different, but same result). – Eric Engel Apr 30 '15 at 16:27
  • It seems this isn't true for gradle 4.1 anymore. I never even had a sourceSets declaration in my build.gradle before 4.1. I also needed to give it the path to manifest, source and res as it didn't find NOTHING after the update. I am totally convinced they just hate app-devs. – FrankKrumnow Nov 04 '20 at 15:18
2

AIDL files need to be generated, that's why sometimes when you need to declare a class that is located in an AIDL file, you first have to build these AIDL files before Android Studio can resolve their content.

Scaraux
  • 3,841
  • 4
  • 40
  • 80
0

run

./gradlew assembleDebug

or

gradle assemble

You can also run the task (assemble) under gradle -> build -> assemble