web-dev-qa-db-fra.com

L'application Android se bloque lorsque des notifications OneSignal Push sont envoyées

L'application Android se bloque juste après l'envoi de la notification push. .__ Je reçois cette erreur. J'ai essayé de regarder d'autres réponses de stackoverflow mais cela n'a pas aidé. 

Veuillez vérifier le code (build.gradle) et l'erreur ci-dessous.

Ne comprenez pas pourquoi cela ne fonctionne pas: P. Veuillez vérifier le code (build.gradle) et l’erreur ci-dessous.

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
}
5
akkk

Vous avez oublié d'appliquer le plug-in OneSignal Gradle. Selon la documentation , vous devriez ajouter 

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'

au sommet de votre app/build.gradle

Appliqué à votre fichier, il devrait ressembler à ceci:

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]'
}
8
Ondrej Karmazin

One Signal ne peut pas fonctionner, sa documentation n’a pas été lue attentivement. Il faut que la FCM fonctionne. Ils ont un plugin qui ajoutera automatiquement toutes les dépendances. Ajoutez ce code à votre application 

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' }
}
1
Suhaib Roomy