Firebase App unable to Compile on Android with AAPT error

What @helpmelearn says is correct. I know it’s a default policy of Google to introduce breaking changes and only support the Android ecosystem, so all plugin maintainers have to keep their plugins up-to-date.

But what is the right course of action here for us developers? Should we follow the releases of say e.g. Firebase and be prepared for breaking changes? This seems like a counter-intuitive way of plugins to depend on --> independent maintainers (you guys are doing god’s work) who depend on --> Google’s breaking changes?

We suddenly have a breaking build in our pipeline and we can’t release our app.

There should be a way to force a Firebase / PlayServices version that is stil compatible with SDK version 27 (and so Ionic 3) - any clue?

I’m having the same problem and I’ve been trying to solve it all day without success. Has anyone found a solution?

Same issue + 1

No solution so far…

On the same boat, been trying all day to fix this issue. Any help would be appreciated.

1 Like

Finally found a solution, based on a response from SO:

I may have deleted platforms folder beforehand

  1. Run:
    ionic cordova platform rm android
  2. Run:
    ionic cordova platform add android@8.0.0
  3. Run:
    ionic cordova plugin add cordova-plugin-androidx
  4. Run:
    ionic cordova plugin add cordova-plugin-androidx-adapter
  5. Make sure your gradle.properties has:
    cdvMinSdkVersion=19
  6. Make sure your build.gradle has:
    project.ext { defaultBuildToolsVersion="28.0.3" //String defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4 defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default }
  7. Make sure your confix.xml has:
    <preference name="android-minSdkVersion" value="19" />

This person explains the problem pretty well on his answer, so i encourage you to read it.

41 Likes

This has worked! Many thanks

thanks dude!. you saved my life :smiley:

this method works, thank you very much.

UnhandledPromiseRejectionWarning: Error [ERR_UNHANDLED_ERROR]: Unhandled error. (The platform “android” does not appear to be a valid cordova platform. It is missing API.js. android not supported.)

@JorgeU i am getting the above error while rrunning the app. do i need to update anyother plugin?

Did you not get any error related to the Crashlytics / Firebase / Fabric?:

ERROR - Crashlytics Developer Tools error.
java.lang.IllegalArgumentException: Crashlytics found an invalid API key: null.

What version of Firebase are you using now?

2 Likes

Yes i got the Crashlytics error as well

Using this version of firebase plugin works for me

run this commande :
ionic cordova plugin add https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue

https://github.com/arnesson/cordova-plugin-firebase/issues/1084#issuecomment-503433000

3 Likes

I am using angularfire 2 , and i did not use firebase plugin directly but getting the fontvariantSettings issue.

What version of google-services are you using?
Also had this and got fixed in google-services 4.2.0

I now reverted to these steps: https://github.com/arnesson/cordova-plugin-firebase/issues/1081#issuecomment-503135862, only had to remove and add the android platform again after I added his version of the cordova-plugin-firebase. Then these versions were in android/build.gradle:

classpath 'com.google.gms:google-services:4.2.0' // google-services dependency from cordova-plugin-firebase
classpath 'io.fabric.tools:gradle:1.25.4' // fabric dependency from cordova-plugin-firebase 

I can finally build again but I am worried about who will maintain the fixed cordova-plugin-firebase

For me the simplest working solution without modifying any plugins or cordova-android was to add the following to the build gradle (or to build-extras.gradle):

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'
    }
}

it forces your apk to work as it did before the google breaking changes which I think is the safest way not to break other plugins.

1 Like

getting like this

Could not find any version that matches androidx.annotation:annotation:28.+.
Versions that do not match:
- 1.1.0
- 1.1.0-rc01
- 1.1.0-beta01
- 1.1.0-alpha02
- 1.1.0-alpha01
- + 8 more
Required by:
project :app
Could not find any version that matches androidx.legacy:legacy-support-v4:28.+.
Versions that do not match:
- 1.0.0
- 1.0.0-rc02
- 1.0.0-rc01
- 1.0.0-beta01
- 1.0.0-alpha3
- + 1 more
Required by:
project :app
Could not find any version that matches androidx.appcompat:appcompat:28.+.
Versions that do not match:
- 1.1.0-beta01
- 1.1.0-alpha05
- 1.1.0-alpha04
- 1.1.0-alpha03
- 1.1.0-alpha02
- + 9 more
Required by:
project :app

Hello,

I am trying to implement this solution but I am having some trouble.

What gradle version are you using? What version of Android Studio?

I’ve implemented all the steps indicated above, in addition to replacing the cordova firebase plugin with this:

ionic cordova plugin add https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue

I am getting this error in Android Studio:

Error:(40, 0) Minimum supported Gradle version is 4.10.1. Current version is 4.1.

Please fix the project's Gradle settings.
<a href="fixGradleVersionInWrapper">Fix Gradle wrapper and re-import project</a><br><a href="openGradleSettings">Gradle settings</a>

In /platforms/android/gradle/gradle.wrapper.properties I have:

#Wed Jun 19 13:26:40 BST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

UPDATE:

Manage to solve the issues with mzepeda’s answer below.

Many thanks!
I do not know if they saw but they have already upgraded to version 4.0.0. In my case, I just needed to do the following:

ionic cordova platforms rm android
ionic cordova platform add android@8.0.0
cordova plugin add cordova-plugin-firebase-lib@4.0.0
1 Like