Ionic Cordova app stopped compiling after Google&#

2020-01-25 05:38发布

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

10条回答
贼婆χ
2楼-- · 2020-01-25 06:12

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.

查看更多
一夜七次
3楼-- · 2020-01-25 06:14

Remove the folder node_modules and file package-lock.json, then at terminal run:

npm install
查看更多
聊天终结者
4楼-- · 2020-01-25 06:21

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
查看更多
Anthone
5楼-- · 2020-01-25 06:21
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
查看更多
做自己的国王
6楼-- · 2020-01-25 06:25

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

查看更多
贼婆χ
7楼-- · 2020-01-25 06:26

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

查看更多
登录 后发表回答