活到老學(xué)到學(xué)菇曲,我做到了
學(xué)完Java學(xué)Kotlin
學(xué)完Kotlin又填坑
一骤公、起因
由于kotlin-android-extensions被廢棄了戚炫,所以之前用kotlin寫的代碼都要面臨著修改的問題哀军。嘗試過還是用findByViewId吧仁堪,完全沒有問題哮洽。就是代碼量增加了好多,并且影響到工作量率了弦聂。還是不能接受鸟辅。
當(dāng)在所有android {
中添加了
buildFeatures {
viewBinding true
}
然后同步。一定要記得同步莺葫。
二匪凉、無權(quán)訪問ViewBuilding
編寫binding代碼時
binding = ActivityAccountDisableBinding.inflate(layoutInflater)
setContentView(binding.root)
報了一個錯誤
Cannot access 'android.viewbinding.ViewBinding' which is a supertype of 'com.qeebike.account.databinding.ActivityAccountDisableBinding'. Check your module classpath for missing or conflicting dependencies
無權(quán)訪問,在
已經(jīng)看到viewbinding已經(jīng)加載了捺檬,但是為何沒有權(quán)限了再层。問了好多度娘,狗爸堡纬,Bing哥聂受。但是還是不行,沒有找到答案烤镐。
三蛋济、 瞎貓碰到死老鼠
對比了其他項目一切都是正常配置的,可其他項目就沒有問題职车。最后無腦嘗試復(fù)制配置后瘫俊。將gradle.properties中的內(nèi)容
## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
#Mon Jan 16 14:18:22 CST 2017
org.gradle.jvmargs=-Xmx1536m
android.injected.testOnly=false
修改為
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableD8=true
android.injected.testOnly=false
android.useAndroidX=true
android.enableJetifier=true
問題解決。似乎與某個配置有關(guān)悴灵。!_!
Cannot access 'android.viewbinding.ViewBinding' which is a supertype of ''. Check your module classpath for missing or conflicting dependencies.
// END 問題是解決了扛芽,如果有人知道原因,記得留言告知下积瞒。多謝川尖。