MainActivity cannot be converted to LifecycleOwner
我以livecycle Owner的身份使用它,但是它被拒绝了,您在图片中看到了一个错误.
我在API 25上工作,我这个问题可能与这个版本有关
这是关于我的SDK的信息
compileSdkVersion 25buildToolsversion '25.0.2'
这是我的代码:
private voID retrIEveTasks() { Log.d(TAG, "Actively retrIEving the tasks from the DataBase"); // Extract all this logic outsIDe the Executor and remove the Executor // Fix compile issue by wrapPing the return type with liveData liveData<List<TaskEntry>> tasks = mDb.taskDao().loadAllTasks(); // Observe tasks and move the logic from runOnUiThread to onChanged tasks.observe(this, new Observer<List<TaskEntry>>() { @OverrIDe public voID onChanged(@Nullable List<TaskEntry> taskEntrIEs) { Log.d(TAG, "Receiving database update from liveData"); mAdapter.setTasks(taskEntrIEs); } });}
我将liveData依赖项放在了Gradle中
compile "androID.arch.lifecycle:extensions:1.0.0"annotationProcessor "androID.arch.lifecycle:compiler:1.0.0"
如果有人知道问题的原因,请告诉我
解决方法:
如您所见here,lifecycleOwner已添加到支持库26.1.0中.解决问题的最简单方法是升级支持库版本.
总结以上是内存溢出为你收集整理的java-不兼容的类型:MainActivity无法转换为LifecycleOwner全部内容,希望文章能够帮你解决java-不兼容的类型:MainActivity无法转换为LifecycleOwner所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)