4

I would like to use a custom annotation in order to include more code to the AIDL's generated code.

In the android documentation, there is a reference saying we can use annotations like @nullable, but when i add that annotation, it gives a compile error.

I would like to be able to have an AIDL function like the following:

interface AppcoinsBilling {
  @MyAnnotation String test();
}

Is that possible?

Are you guys able to use annotations in AIDL files? Is there any other friendly way to change the generated code?

Thanks for helping!

Fábio Costa
  • 41
  • 1
  • 2
  • In terms of the problem you are seeing now, try `@Nullable`. I have not used annotations in AIDL, as it would require both the client and the service to have a definition for the annotation. – CommonsWare Apr 29 '19 at 13:07
  • It doesn't work. As soon as I insert the ```@``` it shows an error. I'm wondering if the documentation is wrong. – Fábio Costa Apr 29 '19 at 13:21
  • It's certainly possible -- there are a lot of documentation bugs. The standard annotation for this uses a capital `N`, which is why I was hoping that was the problem. – CommonsWare Apr 29 '19 at 13:28
  • Well, i opened an issue on the documentation platform, I'll this post updated. – Fábio Costa Apr 30 '19 at 13:54
  • have you resolved this issue? I also want and can't use `@nullable`, because `'@' unexpected`... (code: `@nullable User registerUser(String name)` – snachmsm Sep 15 '21 at 08:13
  • I ended up using other approach. At the time I opened [this](https://issuetracker.google.com/issues/131618219) issue, i'm not sure if you can open it. It was marked as obsolete. – Fábio Costa Sep 16 '21 at 10:03

0 Answers0