android-studio can't find an aidl interface for use in class
Asked Answered
S

4

13

I have an interface defined in the aidl but I can't extend it or find it any way. The ide just tells me: Can not resolve symbol 'KeyEventListener' Any idea how to fix this?

Additional infos:

  • KeyEventListener is the name of the interface defined in KeyEventListener.aidl
  • KeyEventListenerImpl is the class which extends the interface Stub
  • KeyEventListener just contains one method named 'void doIt();' and is well formatted;

I know android-studio is some thing like a pre-alfa but like it very much and would be very happy if some one could halp me out on this!

enter image description here

Sabu answered 16/5, 2013 at 19:58 Comment(0)
C
21

If it's 2023 and you switched from gradle 7 to 8 then I might have a fix.

There is a gradle property called buildFeatures.aidl. It needs to be true to compile aidl files. In gradle version 7 the default is true. But the default has been changed to false in gradle 8.

So if your aidl file is in the default app module you need to edit app/build.gradle. Please don't copy/paste but put the line "aidl true" at the right place in your file instead. The hierarchy is like this:

android {
    buildFeatures {
        aidl true
    }
}
Codfish answered 20/9, 2023 at 14:51 Comment(2)
"If your aidl file is in the default app module..." and if it is in a different module, you can add this in the build.gradle file for that module. πŸ‘ – Antietam
@Codfish I love bro :) You saved my life. – Vain
G
17

In my case Clean and Rebuild project solved my problem.

Glynisglynn answered 12/11, 2014 at 9:23 Comment(0)
S
12

You are probably best off having a look at The Gradle Plugin User Guide for Android.

Gradle, by default, requires a particular directory structure. If you want to use Gradle with a directory structure that most Android devs are accustomed to, you'll need to put the following (from the above-mentioned link) inside the "android" block.

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }
}

After you've done this, do a clean and rebuild to be on the safe side.

Personally, I just adapt my projects to fit the new convention.

Shiver answered 19/5, 2013 at 10:16 Comment(2)
That is correct. If you are using the new structure, remember that aidl files now go in src/main/aidl and not src/main/java. – Ewart
google should really add an infobox about this if it detects aidl elsewhere – Metaplasia
D
4

Created a directory aidl under src/main.

Then created the new aidl file package structure and moved aidl file into it.

Rebuilt and it was done.

I followed this post

Decoy answered 18/6, 2015 at 2:28 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.