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