When I upgraded [email protected]
to [email protected]
I've got a build problem when I run cordova build android --release --buildconfig=build.json
Problems:
* 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.
I've already tried:
- Updated some dependencies outdated
- Remove
cordova-android-play-services-gradle-release
cordova-android-support-gradle-release
cordova-support-google-services
- Add in
config.xml
<preference name="GradlePluginGoogleServicesEnabled" value="true" />
and<preference name="GradlePluginGoogleServicesVersion" value="4.3.8" />
but when I did that, I've got another error:
* 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 Framework: ionic-angular 3.9.8
@ionic/app-scripts: 3.2.4
Cordova CLI: 10.0.0
Cordova Platorms: android 10.1.1
NodeJS: 12.19.0
Android SDK Tools: 26.1.1
CodePudding user response:
Really big thanks for your question & description of the problem, because it helped me to upgrade from cordova-android 9.1.0 to 10.1.1 :-).
And i think i can solve your problem. This error is thrown, because google services plugin is registered twice (apply plugin: 'com.google.gms.google-services') in gradle files, e.g.: platforms/android/app/build.gradle. You just have to comment/remove one of these imports.
Because cleaning files manually every time is very annoying, i created a bash script (= working on Mac OS), which comments the second import automatically: 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
To start the script automatically before building, i use ionic building scripts/hooks in package.json:
"scripts": {
...
"ionic:build:before": "./scripts/fix_android.sh",
"ionic:build:after": "",
...
CodePudding user response:
I also have the same build isuue from last 15 days. and i am unable to build my app can anyone found any solution?