[英]Ionic Cordova Android build fetches cordova-android 9 instead of 10
[英]Build failing after upgrade cordova-android 10
當我將cordova-android@9.0.0
升級到cordova-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.
離子 CLI:5.4.16
離子框架:離子角3.9.8
@ionic/app-scripts: 3.2.4
科爾多瓦 CLI:10.0.0
Cordova 平台:安卓 10.1.1
NodeJS:12.19.0
Android SDK 工具:26.1.1
非常感謝您的問題和對問題的描述,因為它幫助我從cordova-android 9.1.0 升級到10.1.1 :-)。
我想我可以解決你的問題。 拋出此錯誤,因為谷歌服務插件在 gradle 文件中注冊了兩次(應用插件:'com.google.gms.google-services'),例如: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
要在構建之前自動啟動腳本,我在package.json 中使用了離子構建腳本/鈎子:
"scripts": {
...
"ionic:build:before": "./scripts/fix_android.sh",
"ionic:build:after": "",
...
我也有過去 15 天相同的構建問題。 我無法構建我的應用程序 誰能找到任何解決方案?
就我而言,提供的答案都沒有幫助。 在config.xml-fix 中查看config.xml-fix中的解決方案,也許對某些人會有所幫助。
我有 9.1.0 版本的“cordova-android”,它不支持 Android API 30+ Android API 級別和 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提出的 sh 腳本。
順便說一句,當我試圖在cordova-android 10 版上解決這個問題時——這個代碼塊甚至沒有出現在“build.gradle”中。
什么也有幫助:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.