首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Cordova Android构建错误:":app:processReleaseGoogleServices‘(键入'GoogleServicesTask')“

Cordova Android构建错误:":app:processReleaseGoogleServices‘(键入'GoogleServicesTask')“
EN

Stack Overflow用户
提问于 2021-11-05 18:54:16
回答 2查看 2.5K关注 0票数 1

电流行为

在尝试为Android构建Ionic Cordova应用程序时,我得到了以下错误:

构建命令:ionic cordova build android --prod --release

代码语言:javascript
运行
复制
    Task :app:processReleaseGoogleServices FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Some problems were found with the configuration of task ':app:processReleaseGoogleServices' (type 'GoogleServicesTask').
      - In plugin 'com.google.gms.googleservices.GoogleServicesPlugin' 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.googleservices.GoogleServicesPlugin' type 'com.google.gms.googleservices.GoogleServicesTask' field 'packageNameXOR1' without corresponding getter has been annotated with @Input.
        
        Reason: Annotations on fields are only used if there's a corresponding getter for the field.
        
        Possible solutions:
          1. Add a getter for field 'packageNameXOR1'.
          2. Remove the annotations on 'packageNameXOR1'.
        
        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.googleservices.GoogleServicesPlugin' type 'com.google.gms.googleservices.GoogleServicesTask' field 'packageNameXOR2' without corresponding getter has been annotated with @Input.
        
        Reason: Annotations on fields are only used if there's a corresponding getter for the field.
        
        Possible solutions:
          1. Add a getter for field 'packageNameXOR2'.
          2. Remove the annotations on 'packageNameXOR2'.
        
        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.googleservices.GoogleServicesPlugin' type 'com.google.gms.googleservices.GoogleServicesTask' field 'quickstartFile' without corresponding getter has been annotated with @InputFile, @Optional.
        
        Reason: Annotations on fields are only used if there's a corresponding getter for the field.
        
        Possible solutions:
          1. Add a getter for field 'quickstartFile'.
          2. Remove the annotations on 'quickstartFile'.
        
        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.googleservices.GoogleServicesPlugin' type 'com.google.gms.googleservices.GoogleServicesTask' field 'searchedLocation' without corresponding getter has been annotated with @Input.
        
        Reason: Annotations on fields are only used if there's a corresponding getter for the field.
        
        Possible solutions:
          1. Add a getter for field 'searchedLocation'.
          2. Remove the annotations on 'searchedLocation'.
        
        Please refer to https://docs.gradle.org/7.1.1/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
    
    You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
    
    See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
    
    BUILD FAILED in 6s
    4 actionable tasks: 2 executed, 2 up-to-date
    Command failed with exit code 1: /Users/derekmiller/Zogo/Zogo-Frontend/platforms/android/gradlew :app:bundleRelease -b /Users/derekmiller/Zogo/Zogo-Frontend/platforms/android/build.gradle
    [ERROR] An error occurred while running subprocess cordova.
            
            cordova build android --release exited with exit code 1.

这个构建错误是在从cordova-android 8.1.1升级到10.1.1之后开始的。我们被迫做出这一改变,以便能够针对Android 30。

期望行为

成功构建的应用程序

我试过什么

大多数有此错误的其他人表示,可以通过确保google服务版本是4.3.8

  • We来解决这个问题,直接在build.gradle

  • We中设置classpath com.google.gms:google-services:4.3.8也试图通过在config.xml

中添加以下内容来解决这个问题

代码语言:javascript
运行
复制
   <preference name="GradlePluginGoogleServicesEnabled" value="true" />
   
   <preference name="GradlePluginGoogleServicesVersion" value="4.3.8" />

在这两个更改(

)之后,错误持续存在。

在我的config.xml

  • 设置<preference name="AndroidXEnabled" value="true" />

技术细节

  • Ionic CLI: 5.4.16

  • Cordova CLI: 9.0.0

  • Cordova Android: 10.1.1

  • Android工具: 26.1.1

  • OS: macOS Big

  • project.properties:

代码语言:javascript
运行
复制
    target=android-30
    
    android.library.reference.1=CordovaLib
    android.library.reference.2=app
    cordova.gradle.include.1=branch-cordova-sdk/child-rules.gradle
    cordova.system.library.1=com.google.android.play:core:1.8.0
    cordova.gradle.include.2=cordova-plugin-fcm-with-dependecy-updated/child-FCMPlugin.gradle
    cordova.system.library.2=com.google.firebase:firebase-core:16.0.9
    cordova.system.library.3=com.google.firebase:firebase-messaging:18.0.0
    cordova.gradle.include.3=cordova-plugin-ionic/child-cordovapluginionic.gradle
    cordova.system.library.4=com.google.android.gms:play-services-analytics:11.0.1
    cordova.system.library.5=androidx.annotation:annotation:1.1.0
    cordova.system.library.6=com.mixpanel.android:mixpanel-android:5.9.1
    cordova.system.library.7=com.google.android.gms:play-services-base:16.+
    cordova.system.library.8=com.google.firebase:firebase-messaging:16.+
    cordova.system.library.9=androidx.legacy:legacy-support-v4:1.0.0
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-11-15 20:18:37

我通过在根build.gradle中设置一个全局google服务版本来解决这个问题。

代码语言:javascript
运行
复制
    allprojects {
        // other settings
    
        ext {
            GOOGLE_SERVICES_VERSION = '4.3.10'
        }
    }

我试图设置google服务版本的其他方法没有起作用,因为还有其他插件试图使用不同版本的google服务。我相信这样设置版本可以确保他们都使用相同的版本。

票数 0
EN

Stack Overflow用户

发布于 2021-11-12 23:19:21

我只想问你有没有试过这样做,而不改变构建文件本身,如果没有,尝试并重建它,让我知道

升级:

代码语言:javascript
运行
复制
cordova platform remove android
cordova platform add android@10.1.1
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69857992

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档