使用 Google Drive API 了解来自应用程序的 gradle 错误

问题描述 投票:0回答:0

我正在使用 Kotlin 和 android studio 创建一个应用程序。 实际上,我在尝试理解 Google Drive API 文档和构建函数以从我的 google drive 帐户下载/上传文件时感到很痛苦。

我在 Youtube 上找到了 this 教程,我尝试构建并运行它提供的 code。我以为我已经找到了一个可以让我继续我的项目的工作示例,但是代码中已经存在错误。 这个包

import com.google.api.client.extensions.android.http.AndroidHttp
已被弃用所以我用
import com.google.api.client.http.javanet.NetHttpTransport
替换它然后我可以使用
NetHttpTransport()
而不是
AndroidHttp.newCompatibleTransport()
。 但是即使 IDE 没有检测到任何明显的错误,我在运行应用程序时仍然会遇到一些错误:

> Task :app:mapDebugSourceSetPaths FAILED

> Task :app:processDebugGoogleServices FAILED
Execution optimizations have been disabled for task ':app:processDebugGoogleServices' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: 'C:\Users\tessa\Codes\AndroidStudioProjects\Google-Drive-API-Tutorial-in-Android\app\build\generated\res\google-services\debug'. Reason: Task ':app:mergeDebugResources' uses this output of task ':app:processDebugGoogleServices' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.5/userguide/validation_problems.html#implicit_dependency for more details about this problem.

> Task :app:writeDebugSigningConfigVersions UP-TO-DATE

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mapDebugSourceSetPaths'.
> Error while evaluating property 'extraGeneratedResDir' of task ':app:mapDebugSourceSetPaths'
   > Failed to calculate the value of task ':app:mapDebugSourceSetPaths' property 'extraGeneratedResDir'.
      > Querying the mapped value of provider(java.util.Set) before task ':app:processDebugGoogleServices' has completed is not supported

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 
   Searched Location: 
  C:\Users\tessa\Codes\AndroidStudioProjects\Google-Drive-API-Tutorial-in-Android\app\src\debug\google-services.json
  C:\Users\tessa\Codes\AndroidStudioProjects\Google-Drive-API-Tutorial-in-Android\app\src\google-services.json
  C:\Users\tessa\Codes\AndroidStudioProjects\Google-Drive-API-Tutorial-in-Android\app\google-services.json


有人可以帮我解决吗?

android-studio kotlin gradle google-drive-api
© www.soinside.com 2019 - 2024. All rights reserved.