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
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):
Install the latest cordova version (cordova@9.0.0):
npm install -g cordova
Create a new blank cordova project (use the same reverse domain and project name):
cordova create folderName com.projectName.app projectName
Add the latest cordova-android platform (cordova-android@8.0.0):
cordova platform add android
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.
Install cordova-plugin-firebase-lib
cordova plugin add cordova-plugin-firebase-lib
Install cordova-plugin-androidx
cordova plugin add cordova-plugin-androidx
Install cordova-plugin-androidx-adapter
cordova plugin add cordova-plugin-androidx-adapter
Copy the firebase settings files to the root of your project: google-services.json for Android and GoogleService-Info.plist for iOS
Copy resources tags (for icons and splash screens) from your old config.xml and paste them into your new config.xml.
Copy your old res folder to the root of your project (the folder that has all your icons and splash screens).
Replace the content of your new /www folder with the content of the original one.
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.
Remove the folder
node_modules
and filepackage-lock.json
, then at terminal run: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:
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:(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
and
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
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