3

NOTE: This issue has been resolved since Kotlin 1.0 beta version (at least). Keeping the rest of the contents intact for historical reason.


I'm using Kotlin with Android and I'm trying to use some constants from the SDK, like this one:

MediaRecorder.AudioSource.MIC;

It doesn't see AudioSource, so it doesn't see the MIC as well. I've tried changing the imports, cleaning the project. Nothing worked so far. I've temporarily solved it by importing it in a Java class, which worked just fine, and then I just refer to my Java class from my Kotlin file,but I would really like to know why this happens and how I can avoid having that Java class.

2 Answers 2

5

I can confirm, accessing MediaRecorder.AudioSource.MIC doesn't work. However, if you import android.media.MediaRecorder.AudioSource manually, you can access AudioSource.MIC.

Sign up to request clarification or add additional context in comments.

2 Comments

Here's the relevant issue on the Kotlin bug tracker: youtrack.jetbrains.com/issue/KT-6029
Worked! Thank you :) Up-voted the issue, this should be something supported with having to import the whole thing. Wish that at least the IDE would be smart enough in this case.
0

I can confirm it works in Kotlin Beta 4, and probably on older versions.

ContactsContract.Contacts._ID

2 Comments

That's good to hear. Currently on the M14, waiting for the next one :)
The issue referenced in the other answer ([KT-6029](youtrack.jetbrains.com/issue/KT-6029)) appears to still be unresolved. So not sure this made it in the Kotlin betas (M15+)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.