question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue: Android app not building after using PushNotification

See original GitHub issue

Hi. I am developing a multi platform app with Ionic - React using capacitor. ;I was trying to implement push notification feature as documented here and here.

I followed the instructions and add the google-services.json file to the android > app directory. After that sync the Gradle then try to bundle the app. But I encounter with these error messages in build output.


Executing tasks: [:app:assembleDebug] in project /Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/android


> Configure project :capacitor-android
WARNING: API 'variant.getJavaCompiler()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompiler(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API 'variantOutput.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getPackageLibrary(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.

> Task :app:preBuild UP-TO-DATE
> Task :capacitor-android:preBuild UP-TO-DATE
> Task :capacitor-android:preDebugBuild UP-TO-DATE
> Task :capacitor-android:checkDebugManifest UP-TO-DATE
> Task :capacitor-android:processDebugManifest UP-TO-DATE
> Task :capacitor-cordova-android-plugins:preBuild UP-TO-DATE
> Task :capacitor-cordova-android-plugins:preDebugBuild UP-TO-DATE
> Task :capacitor-cordova-android-plugins:checkDebugManifest UP-TO-DATE
> Task :capacitor-cordova-android-plugins:processDebugManifest UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :capacitor-android:compileDebugAidl NO-SOURCE
> Task :capacitor-cordova-android-plugins:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :capacitor-android:packageDebugRenderscript NO-SOURCE
> Task :capacitor-cordova-android-plugins: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:processDebugGoogleServices UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :capacitor-android:compileDebugRenderscript UP-TO-DATE
> Task :capacitor-android:generateDebugBuildConfig UP-TO-DATE
> Task :capacitor-android:generateDebugResValues UP-TO-DATE
> Task :capacitor-android:generateDebugResources UP-TO-DATE
> Task :capacitor-android:packageDebugResources UP-TO-DATE
> Task :capacitor-android:generateDebugRFile UP-TO-DATE
> Task :capacitor-android:prepareLintJar UP-TO-DATE
> Task :capacitor-android:generateDebugSources UP-TO-DATE
> Task :capacitor-android:javaPreCompileDebug UP-TO-DATE

> Task :capacitor-android:compileDebugJavaWithJavac FAILED
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:26: error: package com.google.android.gms.tasks does not exist
import com.google.android.gms.tasks.OnFailureListener;
                                   ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:27: error: package com.google.android.gms.tasks does not exist
import com.google.android.gms.tasks.OnSuccessListener;
                                   ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:28: error: package com.google.firebase.iid does not exist
import com.google.firebase.iid.FirebaseInstanceId;
                              ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:29: error: package com.google.firebase.iid does not exist
import com.google.firebase.iid.InstanceIdResult;
                              ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:30: error: package com.google.firebase.messaging does not exist
import com.google.firebase.messaging.FirebaseMessaging;
                                    ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:31: error: package com.google.firebase.messaging does not exist
import com.google.firebase.messaging.RemoteMessage;
                                    ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:52: error: cannot find symbol
  public static RemoteMessage lastMessage = null;
                ^
  symbol:   class RemoteMessage
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:267: error: cannot find symbol
  public static void sendRemoteMessage(RemoteMessage remoteMessage) {
                                       ^
  symbol:   class RemoteMessage
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:276: error: cannot find symbol
  public void fireNotification(RemoteMessage remoteMessage) {
                               ^
  symbol:   class RemoteMessage
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java:4: error: package com.google.firebase.messaging does not exist
import com.google.firebase.messaging.FirebaseMessagingService;
                                    ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java:5: error: package com.google.firebase.messaging does not exist
import com.google.firebase.messaging.RemoteMessage;
                                    ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java:7: error: cannot find symbol
public class CapacitorFirebaseMessagingService extends FirebaseMessagingService {
                                                       ^
  symbol: class FirebaseMessagingService
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java:16: error: cannot find symbol
  public void onMessageReceived(RemoteMessage remoteMessage) {
                                ^
  symbol:   class RemoteMessage
  location: class CapacitorFirebaseMessagingService
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:95: error: cannot find symbol
    FirebaseMessaging.getInstance().setAutoInitEnabled(true);
    ^
  symbol:   variable FirebaseMessaging
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:96: error: cannot find symbol
    FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(getActivity(), new OnSuccessListener<InstanceIdResult>() {
                                                                                             ^
  symbol:   class OnSuccessListener
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:96: error: cannot find symbol
    FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(getActivity(), new OnSuccessListener<InstanceIdResult>() {
                                                                                                               ^
  symbol:   class InstanceIdResult
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:96: error: cannot find symbol
    FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(getActivity(), new OnSuccessListener<InstanceIdResult>() {
    ^
  symbol:   variable FirebaseInstanceId
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:102: error: cannot find symbol
    FirebaseInstanceId.getInstance().getInstanceId().addOnFailureListener(new OnFailureListener() {
                                                                              ^
  symbol:   class OnFailureListener
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:102: error: cannot find symbol
    FirebaseInstanceId.getInstance().getInstanceId().addOnFailureListener(new OnFailureListener() {
    ^
  symbol:   variable FirebaseInstanceId
  location: class PushNotifications
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/PushNotifications.java:287: error: package RemoteMessage does not exist
    RemoteMessage.Notification notification = remoteMessage.getNotification();
                 ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java:9: error: method does not override or implement a method from a supertype
  @Override
  ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java:11: error: cannot find symbol
    super.onNewToken(newToken);
    ^
  symbol:   variable super
  location: class CapacitorFirebaseMessagingService
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java:15: error: method does not override or implement a method from a supertype
  @Override
  ^
/Users/suleyman/Desktop/Projects/ionic-android-refresher-bug/IonicAndroidRefresher/node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java:17: error: cannot find symbol
    super.onMessageReceived(remoteMessage);
    ^
  symbol:   variable super
  location: class CapacitorFirebaseMessagingService
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
24 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':capacitor-android: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 3s
18 actionable tasks: 1 executed, 17 up-to-date

This is my project build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

This is my app build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.bdt.iar"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven {
        url  "https://dl.bintray.com/ionic-team/capacitor"
    }
    flatDir{
        dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation project(':capacitor-android')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation project(':capacitor-cordova-android-plugins')

}

apply from: 'capacitor.build.gradle'

try {
    def servicesJSON = file('google-services.json')
    if (servicesJSON.text) {
        apply plugin: 'com.google.gms.google-services'
    }
} catch(Exception e) {
    logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
priyankpatcommented, Mar 7, 2020

Add implementation 'com.google.firebase:firebase-messaging:20.1.0' to your dependencies in your app build.gradle.

0reactions
rahul-bmninfotechcommented, Sep 21, 2022

class file for android.app.Service not found

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android build failed after installation · Issue #1467 - GitHub
Task :app:mergeDexDebug > Task :app:mergeDexDebug FAILED Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '-- ...
Read more >
react-native-push-notification issue on building app
This solved the build issue in one of my project. OR. Do the below mentioned changes. In android/app/build.gradle, add the below code to ......
Read more >
Push Notification Troubleshooting for Android - Braze
Troubleshooting scenarios · No “push registered” users showing in the Braze dashboard (prior to sending messages) · Tapping push notification doesn't open the...
Read more >
Notifications - Expo Documentation
Custom notification sounds are only supported when using EAS Build, or in the bare workflow. To add custom push notification sounds to your...
Read more >
Topic messaging on Android - Firebase - Google
Your app can check if it is background restricted using: isBackgroundRestricted(). Build send requests. After you have created a topic, either by subscribing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found