Android:不能使用提供的参数调用以下函数

标签 android kotlin androidx

我刚刚将 android gradle 插件版本提升到 com.android.tools.build:gradle:3.3.0-alpha06 并且我的项目无法编译并出现以下错误:

None of the following functions can be called with the arguments supplied: 
public inline fun <reified W : `Worker;`> 
PeriodicWorkRequestBuilder(repeatInterval: `Duration;`, 
flexTimeInterval: `Duration;`): PeriodicWorkRequest.`Builder;` defined 
in androidx.work
public inline fun <reified W : `Worker;`> 
PeriodicWorkRequestBuilder(repeatInterval: Long, repeatIntervalTimeUnit: `TimeUnit;`): PeriodicWorkRequest.`Builder;` defined in androidx.work

代码非常简单:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    PeriodicWorkRequestBuilder<MyWorker>(1L, TimeUnit.HOURS)
}

class MyWorker: Worker() {
    override fun doWork(): Result {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }
}

这里有一个示例存储库:https://github.com/martinbonnin/TestCanary6

我是否遗漏了什么或者是 android studio 错误?

最佳答案

我一直面临类似的问题,但在我的例子中,编译器错误表明它无法访问 kotlinx 协程库中的类 ¯_(ツ)_/¯。现在我已经恢复了插件更新,并且正在使用命令行工具构建/安装。

编辑:我认为它已在 https://issuetracker.google.com/issues/112723639 中被追踪到

关于Android:不能使用提供的参数调用以下函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51893782/

相关文章:

android - 折叠工具栏标题未居中

android - 错误 : Failed to resolve: androidx. 旧版:legacy-support-v4

Android 应用链接不适用于 Chrome 自定义标签

android - Jetpack Compose 实际上适用于类而不是函数?

android - 无法实现 androidx.appcompat.appcompat :1. 0.0

android - 在 Android 10 中膨胀类 androidx.appcompat.widget.FitWindowsLinearLayout 时出错

java - 调用 AuthUI.getInstance().delete() 时 AuthUI 正在删除什么?

android - 如何在android中使用按钮 TextView 等创建自定义下拉/弹出 View

在 Main 中无法访问 Android SharedPreferences,其他 Activity 还好吗?

java - 使用 kotlin 在菜单中制作可点击的链接