The below link solved my issue.
Android Studio does not detect .aidl files
-
26-06-2022 - |
Domanda
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']
}
Soluzione
Altri suggerimenti
In my case Clean
and Rebuild
project solved my problem.
Hope this helpful.
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.
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.
run
./gradlew assembleDebug
or
gradle assemble
You can also run the task (assemble) under gradle -> build -> assemble