Ionic 4 Cordova - Run Android Firebase error all of a sudden

@dpa99c1 Solution worked for me.
Dont forget to run this command below
cordova platform rm android --nosave && cordova plugin add android --nosave

2 Likes

Solution is only for cordova-plugin-firebase
the error persists , in cordova-plugin-fcm

Ok. I confirm that the below changes make the app compile again, firebase realtime database access works and FCM push notifications are being sent and received:

  1. Delete the file MyFirebaseInstanceIDService.java in folder platforms\android\app\src\main\java\com\gae\scaffolder\plugin

  2. In case you use FCM, remove the last line from platforms\android\cordova-plugin-fcm-with-dependecy-updated<appname>-FCMPlugin.gradle
    ( // apply plugin: com.google.gms.googleservices.GoogleServicesPlugin )

  3. Rebuild

No other changes were done. Above #1 step was suggested by @mrHonest above, but he also had a step: 1 before that relating to adding @Ovverride before the “public void onNewToken(…” statement, but there was no such statement in the file on my installation…

2 Likes

Thanks a lot, it’s working

This seemed to work with FCM. I can build and send/receive messages. Thanks!

A wonderful person opened a pull request in the cordova-firebase-plugin official repo and it works.

Steps I did:

1 - Remove cordova-firebase-plugin with ionic cordova plugin remove cordova-firebase-plugin

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

3 - rm -rf node_modules/ plugins/ platforms/android package-lock.json

4 - ionic cordova platform add android && npm install

5 - In my case I also use firebase js library in an old version becasue the newest ones are not working for me. With that library I always need to reinstall it manually after all the previous steps, so also I did: npm install firebase@4.12.1.

And now it’s working.

7 Likes

how do we fix this?
I only use Firebase for the analytics
on Ionic 3 and Android 6.4.
I tried updating project.properties to use 15+.
Removed Android and Added it back (this reset any project.properties values back) changed them back.
Did a build. got similar error.

This works for me :blue_heart:

Thanks!!! Works for me

Error: Failed to fetch plugin https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue via registry.
Probably this is either a connection problem, or plugin spec is incorrect.

Indeed, as Colo9311 said, It seems refreshing node_modules is very important to get the fix work ! don’t be lazy guys, and go through deleting them all

I suddenly started having the same issue. No other changes to plugins, just basic javascript/typescript code changes. Could this be related somehow to the pending “Deprecated GCM”?

this worked! thank you so much!

thank you, this is working for me

When I try this solution, getting the below error.

Could not find com.google.firebase:firebase-messaging:17.5.0 .
Searched in the following locations:
file:/C:/Users/Admin/AppData/Local/Android/sdk/extras/m2repository/com/google/firebase/firebase-messaging/17.5.0 /firebase-messaging-17.5.0 .pom
file:/C:/Users/Admin/AppData/Local/Android/sdk/extras/m2repository/com/google/firebase/firebase-messaging/17.5.0 /firebase-messaging-17.5.0 .jar
file:/C:/Users/Admin/AppData/Local/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-messaging/17.5.0 /firebase-messaging-17.5.0 .pom
file:/C:/Users/Admin/AppData/Local/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-messaging/17.5.0 /firebase-messaging-17.5.0 .jar

Thank you so much sir.
You saved my day.

sir i got below error:
>Probably this is either a connection problem, or plugin spec is incorrect.
**> **
> Check your connection and plugin name/version/URL.
**> **
> Error: npm: Command failed with exit code 1 Error output:
**> **
> npm ERR! code 128
**> **
> npm ERR! Command failed: git clone --depth=1 -q -b GH-1057-April-05-android-build-issue https://github.com/dpa99c/cordova-plugin-firebase.git /var/root/.npm/_cacache/tmp/git-clone-42b18bd4
**> **
> npm ERR! fatal: could not create leading directories of ‘/var/root/.npm/_cacache/tmp/git-clone-42b18bd4’: Permission denied
**> **
**> npm ERR! **
**> **
> npm ERR! A complete log of this run can be found in:
**> **
> npm ERR! /var/root/.npm/_logs/2019-05-08T05_53_24_361Z-debug.log
**> **
> [ ERROR ] An error occurred while running subprocess cordova .

I followed all your steps. build is successful but while deploying the app to the device or running in the simulator, I am getting the following error:

Executing tasks: [:app:assembleDebug]

Configure project :app
Configuration ‘compile’ in project ‘:app’ is deprecated. Use ‘implementation’ instead.
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)

Task :app:preBuild UP-TO-DATE
Task :CordovaLib:preBuild UP-TO-DATE
Task :CordovaLib:preDebugBuild UP-TO-DATE
Task :CordovaLib:checkDebugManifest UP-TO-DATE
Task :CordovaLib:processDebugManifest UP-TO-DATE
Task :app:preDebugBuild UP-TO-DATE
Task :CordovaLib:compileDebugAidl UP-TO-DATE
Task :app:compileDebugAidl UP-TO-DATE
Task :CordovaLib:packageDebugRenderscript NO-SOURCE
Task :app:compileDebugRenderscript UP-TO-DATE
Task :app:checkDebugManifest UP-TO-DATE
Task :app:generateDebugBuildConfig UP-TO-DATE
Task :app:prepareLintJar UP-TO-DATE
Task :app:mergeDebugShaders UP-TO-DATE
Task :app:compileDebugShaders UP-TO-DATE
Task :app:generateDebugAssets UP-TO-DATE
Task :CordovaLib:mergeDebugShaders UP-TO-DATE
Task :CordovaLib:compileDebugShaders UP-TO-DATE
Task :CordovaLib:generateDebugAssets UP-TO-DATE
Task :CordovaLib:mergeDebugAssets UP-TO-DATE
Task :app:mergeDebugAssets UP-TO-DATE

Task :app:processDebugGoogleServices
Parsing json file: /Users/samarthagarwal/Desktop/FIREBASE/firebase analytics/MMAUIRepo/platforms/android/app/google-services.json

Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
Task :app:processDebugManifest UP-TO-DATE
Task :app:fabricGenerateResourcesDebug
Task :app:generateDebugResValues UP-TO-DATE
Task :app:generateDebugResources UP-TO-DATE
Task :CordovaLib:compileDebugRenderscript UP-TO-DATE
Task :CordovaLib:generateDebugResValues UP-TO-DATE
Task :CordovaLib:generateDebugResources UP-TO-DATE
Task :CordovaLib:packageDebugResources UP-TO-DATE
Task :app:mergeDebugResources
Task :app:splitsDiscoveryTaskDebug UP-TO-DATE
Task :CordovaLib:platformAttrExtractor UP-TO-DATE
Task :CordovaLib:processDebugResources UP-TO-DATE
Task :app:processDebugResources
Task :app:generateDebugSources
Task :CordovaLib:generateDebugBuildConfig UP-TO-DATE
Task :CordovaLib:prepareLintJar UP-TO-DATE
Task :CordovaLib:generateDebugSources UP-TO-DATE
Task :CordovaLib:javaPreCompileDebug

Task :CordovaLib:compileDebugJavaWithJavac
Note: /Users/samarthagarwal/Desktop/FIREBASE/firebase analytics/MMAUIRepo/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Task :CordovaLib:processDebugJavaRes NO-SOURCE
Task :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
Task :app:javaPreCompileDebug

Task :app:compileDebugJavaWithJavac FAILED
/Users/samarthagarwal/Desktop/FIREBASE/firebase analytics/MMAUIRepo/platforms/android/app/src/main/java/com/google/cordova/plugin/BrowserTab.java:21: error: package android.support.customtabs does not exist
import android.support.customtabs.CustomTabsIntent;
^
/Users/samarthagarwal/Desktop/FIREBASE/firebase analytics/MMAUIRepo/platforms/android/app/src/main/java/com/adobe/phonegap/push/PushInstanceIDListenerService.java:9: error: cannot find symbol
import com.google.firebase.iid.FirebaseInstanceIdService;
^
symbol: class FirebaseInstanceIdService
location: package com.google.firebase.iid
/Users/samarthagarwal/Desktop/FIREBASE/firebase analytics/MMAUIRepo/platforms/android/app/src/main/java/com/adobe/phonegap/push/PushInstanceIDListenerService.java:15: error: cannot find symbol
public class PushInstanceIDListenerService extends FirebaseInstanceIdService implements PushConstants {
^
symbol: class FirebaseInstanceIdService
/Users/samarthagarwal/Desktop/FIREBASE/firebase analytics/MMAUIRepo/platforms/android/app/src/main/java/com/google/cordova/plugin/BrowserTab.java:104: error: package CustomTabsIntent does not exist
Intent customTabsIntent = new CustomTabsIntent.Builder().build().intent;
^
/Users/samarthagarwal/Desktop/FIREBASE/firebase analytics/MMAUIRepo/platforms/android/app/src/main/java/com/adobe/phonegap/push/PushInstanceIDListenerService.java:18: error: method does not override or implement a method from a supertype
@Override
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:compileDebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use ‘–warning-mode all’ to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 12s
35 actionable tasks: 9 executed, 26 up-to-date

Can you please help me with this.

I’ve followed all your steps as well . But build has been failed.

:preDebugBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
1

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 7s
    at ChildProcess.whenDone (/Users/test/Documents/projects/ionic/test-project/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
(node:13453) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13453) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1 Like

sir but in my case if i edit our project.properties and add above but after save and close file my changes removed automatically why sir plz help me sir?