第一行代码 第三版 7.6.1简化Preferences中最后一种方法使用KTX拓展库时出现的问题

代码无法运行

错误详情 :Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 Please spcify proper ‘-jvm-target’ option
保错的图片
解决办法:在app/build.gradle 中的andriod 闭包中加入下列代码:

   compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions{
        jvmTarget = JavaVersion.VERSION_1_8
    }

在这里插入图片描述
具体原因可以参考博客:https://blog.csdn.net/nn690960430/article/details/105117149?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522158774038619724811835471%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=158774038619724811835471&biz_id=0&utm_source=distribute.pc_search_result.none-task-blog-2allfirst_rank_v2~rank_v25-1

发布了28 篇原创文章 · 获赞 11 · 访问量 2401

猜你喜欢

转载自blog.csdn.net/Y_an_Y/article/details/105741960