Android SDK Annotations

I am running into troubles with the upgrade to M5 for an android project.

Here’s an example:

I am using

TextView.getCompoundDrawables()

This returns an array[4] of drawables (top, left, bottom and right), with the values at null if there are no drawable defined for one of the sides.

With M4 the signature was:

fun getCompoundDrawables(): Array<Drawable?>?

With M5 it is:

fun getCompoundDrawables(): Array<Drawable>?

Cleary this is wrong and the signature should be:

fun getCompoundDrawables(): Array<Drawable?>

I understand that the new default might be better, and that I am supposed to use annotations to specify the correct signature.

But that’s where I run into troubles.

I do not know how to set the annotation.

In my own java code, I get the option to “Edit custom Kotlin Signature”, but not in the java code from the SDK.

How do I setup my project to use external annotations?
I think my project is setup to write annotations in a dependencies/annotations directory that I specified once, but how do I check that it is working properly. Where is it defined?

I’ve looked at the jar for the jdk annotations and I have only found examples of @NotNull annotations.
What does an annotation like:
  @KotlinSignature(“var values : Set<String?>?”)
Look like in an annotations.xml?

If you grep contents of kotlin-jdk-annotations.jar "KotlinSignature" you'll find a few examples like this:

``

  <item name=‘java.awt.Rectangle boolean contains(java.awt.Point)’>
  <annotation name=‘jet.runtime.typeinfo.KotlinSignature’>
           <val name=“value” val=“&quot;fun contains(p : Point) : Boolean&quot;”/>
  </annotation>
  </item>

In the JDK code, do you get suggestions for other annotations, like this example?

It's the android sdk, not the jdk. No, I do not get those suggestions.

Looks like a bug in the IDE, we'll investigate. Thanks

Strange, but when I try to reproduce it, it works for me. When I press Alt+Enter on getCompoundDrawables() in TextView, I see the following intention menu: ![/uploads/kotlinlang/original/1X/836d7b62949ab2acafc8afa1ee7e5539b2a8676d.png](upload://iKF6Z7oz2Q99wkAmjF64C5z5xgx.png) After that I'm offerered to create new annotations root for android SDK. At last, I get popup where I enter alternative Kotlin signature: ![/uploads/kotlinlang/original/1X/4c7c97ebc3c2dc3694d395962b4dcd2020aca3db.png](upload://aUDe8jPY4jAYdjQZmlDqjdK4wTF.png)

What menu do see when you invoke Alt+Enter on getCompoundDrawables()?

On one machine (this one has Kotlin M5) I see nothing, no option at all. On the other one (still on M4), I see the option to specify the custom Kotlin Signature, but when I click on it, I get an exception:

Couldn’t find function descriptor for getCompoundDrawables in android.widget.TextView: Couldn’t find function descriptor for getCompoundDrawables in android.widget.TextView
java.lang.AssertionError: Couldn’t find function descriptor for getCompoundDrawables in android.widget.TextView

What version of IDEA do you have with Kotlin M5?          

I had 123.150. I have just updated to 123.165 and the problem is gone. I can add the annotation now. Thank you for your help.

No problem. Seems that it was some bug in IDEA which was fixed quickly.