我正在尝试在协同程序中使用 kotlin 将文件添加到 google 驱动器,但出现错误,即使我正在使用协同程序,主线程也会被阻塞

I am trying to add files to google drive using kotlin in cororutines but getting error that main thread will be blocked even if i am using coroutine

这是问题所在 我正在制作文件,然后添加到 google 驱动器,但它说不适当的阻止方法调用。

您应该 运行 长 运行ning 任务在另一个 Thread or use Coroutine 中执行阻塞方法。

通过使用协程,它会是这样的:

    withContext(Dispatchers.IO) {
        launch{
          mfile.execute();
        }
    }