gpt4 book ai didi

android - 升级cordova-android 10后构建失败

转载 作者:行者123 更新时间:2023-12-04 23:40:52 26 4
gpt4 key购买 nike

当我升级 cordova-android@9.0.0cordova-android@10.1.1我在运行 cordova build android --release --buildconfig=build.json 时遇到了构建问题
问题:

* 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.
我已经尝试过:
  • 更新了一些过时的依赖项
  • 删除 cordova-android-play-services-gradle-release cordova-android-support-gradle-release cordova-support-google-services
  • 加入 config.xml <preference name="GradlePluginGoogleServicesEnabled" value="true" /><preference name="GradlePluginGoogleServicesVersion" value="4.3.8" />但是当我这样做时,我遇到了另一个错误:
  • * What went wrong:
    A problem occurred evaluating project ':app'.
    > Failed to apply plugin 'com.google.gms.google-services'.
    > Cannot add extension with name 'googleServices', as there is an extension already registered with that name.
    ionic CLI:5.4.16
    ionic 框架: ionic 角 3.9.8
    @ionic/app-scripts:3.2.4

    Cordova CLI:10.0.0
    Cordova 平台:安卓 10.1.1

    节点JS:12.19.0
    Android SDK 工具:26.1.1

    最佳答案

    非常感谢您提出问题和对问题的描述,因为它帮助我从 cordova-android 9.1.0 升级到 10.1.1 :-)。
    我想我可以解决你的问题。抛出此错误,因为 谷歌服务插件注册两次 (应用插件:'com.google.gms.google-services')在 gradle 文件中,例如:platforms/android/app/build.gradle。您只需要评论/删除这些导入之一。
    因为每次手动清理文件都很烦人,所以我创建了一个 bash 脚本(= 在 Mac OS 上工作),它会自动注释第二次导入: fix_android.sh

    #!/usr/bin/env bash

    echo "Executing fix_android.sh"

    ## comment duplicate import of com.google.gms.google-services plugin
    #file=$(pwd)"/platforms/android/app/build.gradle"
    file="platforms/android/app/build.gradle"
    #echo ${file}
    from="apply plugin: 'com.google.gms.google-services'"
    to="\/\/apply plugin: 'com.google.gms.google-services'"

    if [ -f "$file" ]; then
    if grep -lr "$to" "$file"; then
    echo "File already corrected!"
    else
    change=`sed "s/$from/$to/" < "$file"`
    echo "$change" > "$file"
    #echo "$change"
    echo "Commented duplicate import!"
    fi
    else
    echo ${file}" not found!"
    ls -al platforms/android/app
    fi
    为了在构建之前自动启动脚本,我在 中使用 ionic 构建脚本/ Hook 包.json :
    "scripts": {
    ...
    "ionic:build:before": "./scripts/fix_android.sh",
    "ionic:build:after": "",
    ...
    这是我的实际项目和系统配置
    enter image description here

    关于android - 升级cordova-android 10后构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69856650/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com