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

aichingm picture aichingm · May 16, 2013 · Viewed 12k times · Source

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

Answer

blixtra picture blixtra · May 19, 2013

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.