Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic Cordova app stopped compiling after Google's June 17th Firebase SDK update

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

like image 273
Mario Zepeda Avatar asked Jun 18 '19 17:06

Mario Zepeda


3 Answers

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 [email protected].

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:

  • cordova-plugin-androidx to enable AndroidX in the Android project.
  • cordova-plugin-androidx-adapter to dynamically patch the source code of any plugins using the Support Library to use the AndroidX equivalents.

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
like image 76
DaveAlden Avatar answered Nov 16 '22 05:11

DaveAlden


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 [email protected]

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
like image 8
Shashank Agrawal Avatar answered Nov 16 '22 06:11

Shashank Agrawal


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

[email protected] + 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 ?

like image 5
Nicochu Avatar answered Nov 16 '22 04:11

Nicochu