apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Build failing after upgrade cordova-android 10 #1374

Closed MatheusRBarbosa closed 1 year ago

MatheusRBarbosa commented 2 years ago

Bug Report

Problem

When I upgraded cordova-android@9.0.0 to cordova-android@10.1.1 I've got a build problem when I run: cordova build android --release --buildconfig=build.json

What does actually happen?

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.

Information

I've already tried:

* 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.

Command or Code

Environment, Platform, Device

This problem occurs in windows and linux.

Version information

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

Checklist

matmany commented 2 years ago

It's happening to me too! any ideias??

cool-projects commented 2 years ago

Same issue here. My Ionic 5 application is now breaking. I can't build for API Level 30 as per Google Play Console new requirement as of 1st of November 2021. Any ideas?

MatheusRBarbosa commented 2 years ago

@cool-projects I was about to close this issue because I got a solution that solves the problem. As it is not ideal, I will still leave this issue open to see if any maintainer fixes this issue.

Solution: https://stackoverflow.com/questions/69856650/build-failing-after-upgrade-cordova-android-10

cool-projects commented 2 years ago

Thanks @MatheusRBarbosa for your response. I still can't get my build to work with the line apply plugin: 'com.google.gms.google-services' commented out in the build.gradle file. Also added the <preference name="GradlePluginGoogleServicesVersion" value="4.3.8" /> in the config.xml and no luck. Here is the result.

> Configure project :app
WARNING:: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 7.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.
Error 'Plugin-Version' of 'unspecified' for 'com.android.build.gradle.AppPlugin@96d9e17' is not a valid version number
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Task :app:processDebugGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':app:processDebugGoogleServices' (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 'packageName' 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 'packageName'.
      2. Remove the annotations on 'packageName'.

    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 10s

Project configuration

Node version: v16.13.0 ionic version: 6.18.1

Angular CLI: 11.2.12 Node: 16.13.0 OS: darwin x64

Angular: 11.2.13 ... animations, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Ivy Workspace: Yes

Package Version

@angular-devkit/architect 0.1102.12 @angular-devkit/build-angular 0.1102.14 @angular-devkit/core 11.2.12 @angular-devkit/schematics 11.2.12 @angular/cdk 11.2.12 @angular/cli 11.2.12 @angular/material 11.2.12 @schematics/angular 11.2.12 @schematics/update 0.1102.12 rxjs 6.6.7 typescript 4.0.7

bradeaton commented 2 years ago

I'm running into the exact same error. 'com.google.gms.google-services' is not listed twice in my build.gradle. I tried commenting it out anyway but no change. And, I also added \<preference name="GradlePluginGoogleServicesVersion" value="4.3.8" \/> to config.xml.

Any fixes for this?

Project configuration

Node version: 16.13.0 Ionic version: 6.18.1 Angular CLI: 10.0.8 OS: darwin x64

@angular-devkit/build-angular@0.1100.7 @angular/cli@10.0.8 @angular/common@10.0.14 @angular/compiler-cli@10.0.14 @angular/compiler@10.0.14 @angular/core@10.0.14 @angular/forms@10.0.14 @angular/language-service@10.0.14 @angular/platform-browser-dynamic@10.0.14 @angular/platform-browser@10.0.14 @angular/router@10.0.14

cool-projects commented 2 years ago

@bradeaton FYI, I managed to get my issue fixed by removing the Cordova Android platform

  1. ionic Cordova platform rm Android
  2. Then add platform again this time without the @latest so that I add the version 9.x ionic Cordova platform add android Android version 10.x has issues. Hope this helps.
bradeaton commented 2 years ago

@cool-projects, will 9.x allow you to target Android SDK 30? My understand was that 10.x was required to do that and Google will not accept an apk that doesn't target 30.

cool-projects commented 2 years ago

@bradeaton Just make sure you have the config.xml updated with <preference name="android-targetSdkVersion" value="30" /> then you are good.

bradeaton commented 2 years ago

Thanks @cool-projects, that did seem to work. At some point, I had gotten it stuck in my head that I had to be on android 10 to target SDK 30.

mcasami-frit commented 2 years ago

@bradeaton Just make sure you have the config.xml updated with <preference name="android-targetSdkVersion" value="30" /> then you are good.

This answer solves my issue! THANKSSSS 🥇

JLWINC commented 2 years ago

@mcasami-frit android@9.x support SDK 30 ?

satyammca commented 2 years ago

Facing same issue as described by MatheusRBarbosa

breautek commented 2 years ago

@mcasami-frit android@9.x support SDK 30 ?

cordova-android 9.x doesn't officially support SDK 30, but cordova-android@9 itself will run SDK 30. Mileage may vary depending on your used plugins.

pablonunessilva commented 2 years ago

So, I am try apply this but my app show me white screen. Can a help me ?

noriellecruz commented 2 years ago

I was able to fix the issue, it seems that cordova-plugin-whitelist has been deprecated and will not be included in the future versions of cordova-android. Read here: https://www.npmjs.com/package/cordova-plugin-whitelist

  1. Remove cordova-plugin-whitelist from your project: cordova plugin rm cordova-plugin-whitelist
  2. Update GradlePluginGoogleServicesVersion in config.xml to 4.3.8
  3. Remove android platform then add it again: cordova platforms rm android && cordova platforms add android

It should work fine.

krem06 commented 2 years ago

Still getting this problem using cordova 11 with cordova-android 10.1.1... I tried above solutions and so far I could only make it work with cordova-android 9.

For now we can compile for sdk30 using cordova-android 9 but this problems might get really problematic in futur sdk updates...

louis123562 commented 2 years ago

The very interesting part on this issue is that this plugin works fine in a blank app. but if you add any other cordova plugin, it cannot compile anymore. very strange...

joshswork commented 2 years ago

So, I am try apply this but my app show me white screen. Can a help me ?

I have the same issue. anyone know why there android app's are showing white screen after splash hide with: "cordova-android": "^9.1.0",

pedroramosdiehl commented 2 years ago

@joshswork same issue here. I get this message on logcat java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

breautek commented 1 year ago

There seems to be a mix of different issues in this thread,

Using the mock test google services I was able to build/compile successfully with the following configuration.

<preference name="GradlePluginGoogleServicesEnabled" value="true" />
<preference name="GradlePluginGoogleServicesVersion" value="4.3.8" />
  • 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. ...

This appears to be caused by a third-party plugin.

  • 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.

This also appears to be caused by a third-party plugin possibly also adding google services.

If this is the case, then it would be up to plugin maintainers to update their codebase. Or perhaps the plugin is obsolete because it's doing (or attempting to do) what Cordova is already doing.

If you believe this is still a bug inside Cordova's framework, we will need a minimal sample app to reproduce this issue.

Ashaba commented 1 year ago

In addition to the above suggestion, ensure you go ahead and remove the plugins related to Google services. For example

ionic cordova plugin rm cordova-support-google-services

breautek commented 1 year ago

Closing as stale. If the issue appears to occur on cordova-android@11 I suggest trying the above advice at https://github.com/apache/cordova-android/issues/1374#issuecomment-1129191548 and https://github.com/apache/cordova-android/issues/1374#issuecomment-1331299754.

If neither works, then please open a new issue with updated information.

hirushacooray commented 2 months ago

@Ashaba After removing the plugin cordova-support-google-services, I'm getting the below error. I'm using cordova-android 12.0.1 as I need to target android SDK version 33. Is there a fix for this issue?

File google-services.json is missing. The Google Services Plugin cannot function without it.

Ashaba commented 1 month ago

@hirushacooray , you will need to have the google-services.json file under your /app directory. That is usually downloaded from Firebase Console under your project. You can read more about that here