Android-Cordova 10.0.1 任务:app:processDebugGoogleServices 失败

Android-Cordova 10.0.1 Task :app:processDebugGoogleServices FAILED

我已将 cordova-android 版本从 9.0 升级到 10.0.1,在使用 -ionic cordova build android

构建 Cordova 应用程序时遇到以下问题

错误:

Task :app:processDebugGoogleServices FAILED
Some problems were found with the configuration of task ':app:processDebugGoogleServices' (type 'GoogleServicesTask').
  - In plugin 'com.google.gms.google-services' type 'com.google.gms.googleservices.GoogleServicesTask' field 'intermediateDir' without corresponding getter has been annotated with @OutputDirectory.

    Reason: Annotations on fields are only used if there's a corresponding getter for the field.

    Possible solutions:
      1. Add a getter for field 'intermediateDir'.
      2. Remove the annotations on 'intermediateDir'.

    Please refer to https://docs.gradle.org/7.1.1/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.    
  - In plugin 'com.google.gms.google-services' type 'com.google.gms.googleservices.GoogleServicesTask' field 'packageNameXOR1' without corresponding getter has been annotated with @Input.

信息:

Cordova CLI - 10.0.0

科尔多瓦 android: 10.0.1

节点:v12.18.2

npm: 6.14.13

项目安装插件:

@havesource/cordova-plugin-push: 2.0.0
    cordova-android-play-services-gradle-release: 4.0.0
    cordova-background-geolocation-lt: 4.0.1
    cordova-plugin-advanced-http: 3.1.0
    cordova-plugin-android-permissions: 1.1.2
    cordova-plugin-androidx-adapter: 1.1.3
    cordova-plugin-androidx: 3.0.0
    cordova-plugin-app-launcher: 0.4.0
    cordova-plugin-app-version: 0.1.12
    cordova-plugin-appminimize: 1.0.1
    cordova-plugin-background-fetch: 7.0.1
    cordova-plugin-badge: 0.8.8
    cordova-plugin-camera: 5.0.2
    cordova-plugin-device: 2.0.3
    cordova-plugin-file-opener2: 3.0.5
    cordova-plugin-file: 6.0.2
    cordova-plugin-filepath: 1.6.0
    cordova-plugin-googlemaps: 2.7.1
    cordova-plugin-inappbrowser: 5.0.0
    cordova-plugin-ionic-keyboard: 2.2.0
    cordova-plugin-ionic-webview: 4.2.1
    cordova-plugin-local-notification: 0.9.0-beta.2
    cordova-plugin-market: 1.2.0
    cordova-plugin-ms-azure-mobile-apps: 2.0.2
    cordova-plugin-network-information: 2.0.2
    cordova-plugin-sim: 1.3.3
    cordova-plugin-sms-retriever-manager: 1.0.2
    cordova-plugin-splashscreen: 6.0.0
    cordova-plugin-statusbar: 2.4.3
    cordova-plugin-twilio-chat: 3.3.0
    cordova-plugin-whitelist: 1.3.4
    cordova-sqlite-storage: 6.0.0
    phonegap-plugin-barcodescanner: 8.1.0
    phonegap-plugin-multidex: 1.0.0

谁能知道如何解决这个问题?

它终于对我有用了。我将使用的 gradle 版本更改为 6.7.1 并重新安装了一些过时的 cordova 插件。

使用的插件:

@havesource/cordova-plugin-push 2.0.0 "Cordova Push Plugin"
cordova-plugin-advanced-http 2.5.1 "Advanced HTTP plugin"
cordova-plugin-camera 5.0.0 "Camera"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-facebook4 6.4.0 "Facebook Connect"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-googleplus 8.5.0 "Google SignIn"
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 5.0.0 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-plugin-wkwebview-inject-cookie 1.0.2 "WKWebViewInjectCookie"
cordova-support-google-services 1.1.0 "cordova-support-google-services"

我通过在 config.xml 文件中添加以下首选项解决了这个问题:

<preference name="android-targetSdkVersion" value="30" />
<preference name="AndroidXEnabled" value="true" />
<preference name="GradlePluginGoogleServicesEnabled" value="true" />
 
 <!-- Updated the version of com.google.gms.google-services -->
<preference name="GradlePluginGoogleServicesVersion" value="4.3.8" /> ,

Package.json:

"cordova-android": "^10.1.0"

Gradle版本:7.1.1

就我而言,none 提供的答案很有帮助。 在这里 查看配置中的其他解决方案,也许对某些人会有帮助。

我有 9.1.0 版本的 'cordova-android' 不支持 Android API 30+ Android API Levels and Android Versions

我是如何解决问题的,或者我是如何破解解决方案的: 运行:

  1. cordova 平台 rm android
  2. cordova 平台添加 android

这应该在 platforms\android 中生成一个“build.gradle”文件 然后,手动更改代码的“project.ext”部分并指定您想要的版本,在我的例子中我需要支持 30 API 版本:

project.ext {
  defaultBuildToolsVersion="30.0.0" //String
  defaultMinSdkVersion=23 //Integer - Minimum requirement is Android 5.1
  defaultTargetSdkVersion=30 //Integer - We ALWAYS target the latest by default
  defaultCompileSdkVersion=30 //Integer - We ALWAYS compile with the latest by default
}

你可以修改@Mike(in 1 link)提出的sh脚本来满足这个需求。

顺便说一句,当我试图解决 cordova-android 版本 10 上的问题时 - 此代码块甚至没有出现在“build.gradle”中。

什么也可以提供帮助:

  1. 删除 cordova-plugin-whitelist - 版本 10 不支持它。
  2. 在 SDK 平台管理器中 - 需要下载 API 级别;
  3. 在 SDK 工具管理器中 - 下载所需的构建工具版本;