我正在 Android Studio 3.4.1 中使用 Kotlin 构建 AAR,当我尝试使用 mutableListOf 时,出现可怕的“未解析的引用”错误。
val myBuffer: mutableListOf<Byte>()
I updated Kotlin to the latest version at the time of writing
![enter image description here](https://i.stack.imgur.com/j1cve.png)
In build.gradle, the Kotlin version is also consistently defined.
![kotlinversion](https://i.stack.imgur.com/HeyH0.png)
在模块 build.gradle 中,使用了以下插件:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
从我读到的内容中我了解到,Kotlin 语言插件(包括集合类)应该自动包含在 Android Studio 中。无论如何,我正在使用其他 Kotlin 类,例如ByteArray,没有问题。
根据我在网上找到的建议,我清理并重新构建,还选择了文件|使缓存无效/重新启动并重新构建。它不起作用;参考文献仍未解决。
Kotlin 文档并没有说这个函数已被弃用,这是我发现的另一个可能的原因。
我缺少什么?
您犯了一些拼写错误:使用=
并不是:
:
val myBuffer = mutableListOf<Byte>()
或明确指定类型:
val myBuffer: MutableList<Byte> = mutableListOf<>()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)