5

Android app is crashing just after onesignal push notification is sent. I am getting this error. Tried looking at other stackoverflow answers but it didn't help.

Please check the code (build.gradle) & error below.

Dont understant why is it not working :P Please check the code (build.gradle) & error below.

FATAL EXCEPTION: Firebase-FirebaseMessagingService
    Process: com.mario.childhood.game.videogame, PID: 30163
    java.lang.AbstractMethodError: abstract method "void com.google.firebase.iid.zzb.zzd(android.content.Intent)"
        at com.google.firebase.iid.zzc.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:760)

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 3
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [onesignal_app_id: 'XXXX-310c-4776-ae83-XXXX',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: '22978XXXX'
        ]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.anjlab.android.iab.v3:library:1.0.44'
    testImplementation 'junit:junit:4.12'
    implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
    implementation 'com.google.firebase:firebase-ads:15.0.1'
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
}

build.gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha09'

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

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
akkk
  • 1,457
  • 4
  • 23
  • 41

2 Answers2

10

You forgot to apply the OneSignal gradle plugin. According to the documentation, you should add

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin: [0.10.1, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

to the very top of your app/build.gradle

When applied to your file, it should look like this:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin: [0.10.1, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'


apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 3
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [onesignal_app_id: 'XXXX-310c-4776-ae83-XXXX',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: '22978XXXX'
        ]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.anjlab.android.iab.v3:library:1.0.44'
    testImplementation 'junit:junit:4.12'
    implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
    implementation 'com.google.firebase:firebase-ads:15.0.1'
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
}
Ondrej Karmazin
  • 386
  • 2
  • 12
1

One Signal cannot work on its on, You haven't read their documentation thoroughly. It need FCM to work. They have a plugin which will automatically add all the dependencies. Add this code to your app gradle

buildscript {
repositories {
    maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.1, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
     maven { url 'https://maven.google.com' }
}
Suhaib Roomy
  • 2,501
  • 1
  • 16
  • 22
  • You’re assuming the OP has not read documentation. I had this exact same issue arise around the same time. For two years this had never happened and only recently it started. OneSignal recently updated their documentation to support newer versions of firebase which is why the OP hadn’t seen the changes. – Brandon Stillitano Jun 05 '18 at 02:29