androidfirebasefirebase-realtime-databasefirebaseuionesignal

App crashes on its very first run when using Firebase with onesignal


lately, i have upgraded my firebase and onesignal dependencies to the latest versions, but a strange thing happens, after the app installs for the first time, and i open it, it directly crushes after 1-2 seconds, but when you open it up again the second time, it behaves normally without crushing.

here is my gradle(app-level):

        apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.11.2'
    }
}

repositories {
    maven { url 'https://maven.google.com' }
}


android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.mohammed.skyquestionbank"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        manifestPlaceholders = [
                onesignal_app_id               : 'my_id',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE'
        ]

        multiDexEnabled true

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    dataBinding {
        enabled true
    }

}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:exifinterface:27.1.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.flaviofaria:kenburnsview:1.0.7'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.onesignal:OneSignal:3.10.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.mikhaellopez:circularimageview:3.2.0'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:support-media-compat:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:16.0.4'
    implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
    implementation 'com.firebaseui:firebase-ui-database:4.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.3'
    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 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
    implementation 'com.mikepenz:materialdrawer:6.0.9'
    implementation 'com.mikhaellopez:circularprogressbar:2.0.0'
    implementation 'com.zekapp.library:progreswheelview:1.1.5'
}

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

and here the root level

buildscript {

    repositories {
        google()
        jcenter()
      maven {
          url 'https://maven.fabric.io/public'
      }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.0.1'

        classpath 'io.fabric.tools:gradle:1.25.4'


        // 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"}
    }
}

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

and Here is the crush log:

--------- beginning of crash
10-11 00:26:41.282 5157-5157/com.example.mohammed.skyquestionbank      E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.mohammed.skyquestionbank, PID: 5157
    java.lang.NoSuchMethodError: No static method zzac()Lcom/google      /firebase/iid/zzap; in class Lcom/google/firebase/iid/zzap; or its super     classes (declaration of 'com.google.firebase.iid.zzap' appears in /data/app/com.example.mohammed.skyquestionbank-1/base.apk:classes2.dex)             atcom.google.firebase.messaging.FirebaseMessagingService.zzb(Unknown Source)
    at com.google.firebase.iid.zzb.onStartCommand(Unknown Source)
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2864)
    at android.app.ActivityThread.access$2100(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
10-11 00:26:41.288 1146-1146/? E/EGL_emulation: tid 1146:     eglCreateSyncKHR(1865): error 0x3004 (EGL_BAD_ATTRIBUTE)

Solution

  • so i solved the problem by myself, there seems to be a problem with the latest version of firebase-core and firebase-auth 16.0.4 as they just recently released this october. i had to downgrade them to 16.0.3 to match with my firebase-database 16.0.3. and the crush got away.