26

I'm unable to compile Ionic Cordova App after Firebase Major version update with Breaking Changes, specifically with June 17, 2019 update.

I tried downgrading to Android Cordova 6.3.0 but my project must be 7.0.0.

This is my ionic info:

@ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.2.1
    Cordova Platforms  : android 7.0.0 browser 5.0.4
    Ionic Framework    : ionic-angular 3.9.3

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.1
    npm               : 5.5.1
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Development\android-sdk

Misc:

    backend : pro

This is the error I'm Getting:

:app:processDebugResources C:\Users\mmzep.gradle\caches\transforms-1\files-1.1\core-1.0.0.aar\73b4a83ab5e76f20c84a66b1c8444d08\res\values\values.xml:133:5-70: AAPT: error: resource android:attr/fontVariationSettings not found.

C:\Users\mmzep.gradle\caches\transforms-1\files-1.1\core-1.0.0.aar\73b4a83ab5e76f20c84a66b1c8444d08\res\values\values.xml:133:5-70: AAPT: error: resource android:attr/ttcIndex not found.

C:\Users\mmzep\Desktop\mario\Seven\SevenPassengerApp\platforms\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:95: error: resource android:attr/fontVariationSettings not found. C:\Users\mmzep\Desktop\mario\Seven\SevenPassengerApp\platforms\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:95: error: resource android:attr/ttcIndex not found. error: failed linking references.

Failed to execute aapt

com.android.ide.common.process.ProcessException: Failed to execute aapt

BionicCode
  • 1
  • 4
  • 28
  • 44
Mario Zepeda
  • 273
  • 1
  • 4
  • 8

9 Answers9

47

This build failure is due to a major version release of the Google Play Services and Firebase libaries on June 17.

The new library versions have the following requirements:

  • Upgrade com.android.tools.build:gradle to v3.2.1 or later.
  • Upgrade compileSdkVersion to 28 or later.
  • Update your app to use Jetpack (AndroidX)

The first two requirements can be resolved by updating to use cordova-android@8.0.0.

The third requires that your Android project migrates to using AndroidX (Jetpack). AndroidX is the successor to the widely-used Android Support Library. AndroidX now used by the latest versions of Play Services/Firebase libraries and the Support library is used by many existing plugins such as cordova-plugin-firebase. The two libraries cannot live side-by-side in the same Android build - doing so will lead to build failure.

To resolve this issue, add the following two plugins your Cordova project:

For a working example of how to try this out in a test project, see my comment on this Github issue.

Note: if you are using cordova-plugin-firebase and encountering errors, you can instead use my fork of that plugin which is published as cordova-plugin-firebasex and is fixed to resolve issues caused by the new Firebase SDK:

rm -Rf platforms/android
cordova plugin rm cordova-plugin-firebase
rm -Rf plugins/ node_modules/
npm install
cordova plugin add cordova-plugin-firebasex
cordova platform add android
DaveAlden
  • 30,083
  • 11
  • 93
  • 155
  • 1
    I had a working project so I had to remove the plugins directory `-rf ./plugins` and re add the android plaform `ionic cordova platform rm android` `ionic cordova platform add android@8.0.0` and then @DaveAlden solution worked perfectly. – Mario Zepeda Jun 19 '19 at 15:16
  • 1
    You're a life saver, your solution worked magically after spending hours trying to revert back to previous version. Thanks! – simdrouin Jun 19 '19 at 21:06
  • I have tried this but I am not able to get the token from fcm build is successfull my project is on critical condtion @DanielGoncalves I want you help please can you help me my skype id is: ionic.fiverr – Kishan Oza Aug 15 '19 at 11:18
  • @KishanOza could you add me to your GitHub repository maybe i can have a look at your project username > dan62 – Daniel Goncalves Aug 16 '19 at 05:45
  • Sure its in bitbucket so give me ur email @DanielGoncalves – Kishan Oza Aug 16 '19 at 08:29
  • Having the same issue, but unfortunately I am working with Capacitor, not with Cordova. Already had firebasex plugin installed, and also the androidx plugins installed. Any help? – Emi Mar 26 '20 at 12:18
8

1. First Answer

We have created a PR for this https://github.com/wizpanda/cordova-plugin-firebase-lib/pull/13 but that requires upgrade of cordova-android to 8.0.0.

A workaround is being done for cordova-android 7.x but meanwhile, a discussion is also ongoing whether to keep support for it or not.

2. Edit - Jun 19, 2019

A new version v3.3.0 is released to fix the issue caused by Google Firebase release which supports cordova-android <= 7.1.4. https://github.com/wizpanda/cordova-plugin-firebase-lib/pull/14#issuecomment-503499409

cordova plugin remove cordova-plugin-firebase-lib
# Or if you were using original fork
#cordova plugin remove cordova-plugin-firebase
cordova plugin add cordova-plugin-firebase-lib@3.3.0

3. Edit - Jun 20, 2019

A new version v4.0.1 is released to fix the issue caused by Google Firebase release which supports cordova-android >= 8.0.0. https://github.com/wizpanda/cordova-plugin-firebase-lib/pull/14#issuecomment-503499409

cordova plugin remove cordova-plugin-firebase-lib
# Or if you were using original fork
#cordova plugin remove cordova-plugin-firebase
cordova plugin add cordova-plugin-firebase-lib
Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
5

Having in platform/android/project.properties following settings :

cordova.gradle.include.1=cordova-plugin-firebase/app-build.gradle
cordova.system.library.4=com.google.firebase:firebase-core:+
cordova.system.library.5=com.google.firebase:firebase-messaging:+
cordova.system.library.6=com.google.firebase:firebase-config:+
cordova.system.library.7=com.google.firebase:firebase-perf:+

I had the same issue (error: resource android:attr/ttcIndex not found).

cordova-android@8.0.0 + cordova-plugin-androidx + cordova-plugin-androidx-adapter worked for me perfectly.

Thanks for this solution.

I am just wondering if it is a good long time bet to use those two plugins. Any opinion ?

Nicochu
  • 51
  • 3
5

Follow the sequence below for cordova-android <= 7.1.4

cordova platform remove android
cordova plugin remove cordova-plugin-firebase
cordova plugin add cordova-plugin-firebase-lib@3.3.0
cordova platform add android

cordova-plugin-firebase is now included in cordova-plugin-firebase-lib

Don Pels
  • 51
  • 1
2

I suggest you to try to add in your build-extras.gradle, inside the platform/android folder of your project this:

configurations.all {
    resolutionStrategy {
         force 'com.android.support:support-v4:27.1.1'
         force 'com.google.android.gms:play-services-tagmanager:16.0.8'
         force 'com.google.android.gms:play-services-base:16.1.0'
         force 'com.google.android.gms:play-services-tasks:16.0.1'
         force 'com.google.android.gms:play-services-basement:16.2.0'
         force 'com.google.android.gms:play-services-gcm:16.1.0'
         force 'com.google.android.gms:play-services-stats:16.0.1'
         force 'com.google.android.gms:play-services-location:16.0.0'
         force 'com.google.android.gms:play-services-auth:16.0.1'
         force 'com.google.android.gms:play-services-identity:16.0.0'
    }
}

In this way you will force the build command to ignore the updates and to use the previous versions. You don't even need to change any plugin (nor the android platform version)!

Every time firebase's libs are updated this happens.. and it is very annoying. I'd love to be able to turn off the auto dependency update on build command, but I don't think it is possible.

Leonardo T
  • 61
  • 3
2
ionic cordova platform remove android

ionic cordova plugin remove cordova-plugin-firebase

ionic cordova plugin add cordova-plugin-firebase-lib@3.3.0

(if you removed this npm install --save @ionic-native/firebase@4 install again)

There was a dex merger issue in android 7.0.0 for me. So I have used android 8.0.0

To use android 8.0.0

ionic cordova platform add android@8.0.0

if required install below 2 plugin for android 8.0.0

ionic cordova plugin add cordova-plugin-androidx

and

ionic cordova plugin add cordova-plugin-androidx-adapter
1

Follow these steps if you have tried everything and you cannot build your cordova android project yet.

I've been working on this issue for five days and this is the only solution that works for me (it's a recopilation of solutions and comments, ordered in the sequence I followed to make my projects work):

  1. Install the latest cordova version (cordova@9.0.0):

    npm install -g cordova

  2. Create a new blank cordova project (use the same reverse domain and project name):

    cordova create folderName com.projectName.app projectName

  3. Add the latest cordova-android platform (cordova-android@8.0.0):

    cordova platform add android

  4. Install every plugin that appears on your original project (except cordova-plugin-firebase). I would recomend you to build your app after each plugin installation to check if everything is OK.

  5. Install cordova-plugin-firebase-lib

    cordova plugin add cordova-plugin-firebase-lib

  6. Install cordova-plugin-androidx

    cordova plugin add cordova-plugin-androidx

  7. Install cordova-plugin-androidx-adapter

    cordova plugin add cordova-plugin-androidx-adapter

  8. Copy the firebase settings files to the root of your project: google-services.json for Android and GoogleService-Info.plist for iOS

  9. Copy resources tags (for icons and splash screens) from your old config.xml and paste them into your new config.xml.

<platform name="android">
    <icon src="res/android/drawable-hdpi/icon.png" />
    <icon density="ldpi" src="res/android/drawable-ldpi/icon.png" />
    <icon density="mdpi" src="res/android/drawable-mdpi/icon.png" />
    <icon density="hdpi" src="res/android/drawable-hdpi/icon.png" />
    <icon density="xhdpi" src="res/android/drawable-xhdpi/icon.png" />
</platform>
<platform name="ios">
    <icon height="180" src="res/ios/icon/1024x1024.png" width="1024" />
    <icon height="180" src="res/ios/icon/Icon-60x60@3x.png" width="180" />
    <icon height="60" src="res/ios/icon/Icon-20x20@3x.png" width="60" />
    <icon height="120" src="res/ios/icon/Icon-40x40@3x.png" width="120" />
    <icon height="76" src="res/ios/icon/Icon-76x76@1x.png" width="76" />
    <icon height="152" src="res/ios/icon/Icon-76x76@2x.png" width="152" />
    <icon height="40" src="res/ios/icon/Icon-20x20@2x.png" width="40" />
    <icon height="80" src="res/ios/icon/Icon-40x40@2x.png" width="80" />
    <icon height="57" src="res/ios/icon/Icon-29x29@2x.png" width="57" />
    <icon height="29" src="res/ios/icon/Icon-29x29@1x.png" width="29" />
    <icon height="58" src="res/ios/icon/Icon-29x29@2x.png" width="58" />
</platform>
  1. Copy your old res folder to the root of your project (the folder that has all your icons and splash screens).

  2. Replace the content of your new /www folder with the content of the original one.

  3. Finally, build your project

    cordova build android

In my case, I had two plugins that were in conflict with the new cordova, cordova-android, firebase sdk versions: cordova-plugin-firebase and cordova-plugin-locationservices, and these steps let me continue with my projects.

ulisesvera
  • 131
  • 1
  • 6
-1

Here are the exact steps I did to fix

cordova build android

delete platforms folder

ionic cordova platform remove android
ionic cordova plugin remove cordova-plugin-firebase
ionic cordova plugin add cordova-plugin-firebase-lib@3.3.0
ionic cordova plugin add cordova-plugin-androidx-adapter
cordova build android
ionic cordova platform add android
cordova plugin add cordova-plugin-whitelist
ionic cordova emulate
Jimmy
  • 575
  • 5
  • 10
-1

Solution :
Follow the sequence below for
cordova android platform <= 7.1.4

cordova platform remove android
cordova plugin remove cordova-plugin-firebase
cordova plugin add cordova-plugin-firebase-lib@3.3.0
cordova platform add android

Supriya
  • 481
  • 5
  • 5