错误记录Android Studio 编译时 Kotlin 代码编译报错 ( Not enough information to infer type variable T )

Posted 韩曙亮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误记录Android Studio 编译时 Kotlin 代码编译报错 ( Not enough information to infer type variable T )相关的知识,希望对你有一定的参考价值。





一、报错信息



在 Kotlin 代码中调用

findViewById(R.id.button)

代码 , 编译时报如下错误信息 :

Not enough information to infer type variable T

上午还能编译 , 下午更新了下支持库到 28.0.0 28.0.0 28.0.0 就出现上述错误 ;

按照当前的 Kotlin 规范 , 重新修改 Kotlin 的相关代码 ;





二、解决方案



将组件查找代码修改为如下形式 , 添加泛型 ;

findViewById<View>(R.id.button)

以上是关于错误记录Android Studio 编译时 Kotlin 代码编译报错 ( Not enough information to infer type variable T )的主要内容,如果未能解决你的问题,请参考以下文章

错误记录Android Studio 编译时 Kotlin 代码编译报错 ( Not enough information to infer type variable T )

错误记录Android Studio 编译时 lint 检查报错 ( Could not resolve junit:junit:4.+. )

错误记录Android Studio 编译报错 ( Invalid Gradle JDK configuration found )

错误记录Android Studio 编译时 lint 检查报错 ( Error: Google Play requires that apps target API level 29 or )

错误记录Android Studio 编译报错 ( Execution failed for task ‘:APP_MIDI:lintVitalRelease‘. )

错误记录Android Studio 编译报错 ( Execution failed for task ‘:APP_MIDI:lintVitalRelease‘. )