【错误记录】Android Studio 编译时 Kotlin 代码编译报错 ( Not enough information to infer type variable T )
生活随笔
收集整理的這篇文章主要介紹了
【错误记录】Android Studio 编译时 Kotlin 代码编译报错 ( Not enough information to infer type variable T )
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文章目錄
- 一、報(bào)錯(cuò)信息
- 二、解決方案
一、報(bào)錯(cuò)信息
在 Kotlin 代碼中調(diào)用
findViewById(R.id.button)代碼 , 編譯時(shí)報(bào)如下錯(cuò)誤信息 :
Not enough information to infer type variable T上午還能編譯 , 下午更新了下支持庫(kù)到 28.0.028.0.028.0.0 就出現(xiàn)上述錯(cuò)誤 ;
按照當(dāng)前的 Kotlin 規(guī)范 , 重新修改 Kotlin 的相關(guān)代碼 ;
二、解決方案
將組件查找代碼修改為如下形式 , 添加泛型 ;
findViewById<View>(R.id.button)總結(jié)
以上是生活随笔為你收集整理的【错误记录】Android Studio 编译时 Kotlin 代码编译报错 ( Not enough information to infer type variable T )的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【错误记录】Android Studio
- 下一篇: 【错误记录】Android Studio