OneSignal and Google gms incompatibility
Asked Answered
S

1

1

There is this error I get which you can see below. I found what causes the error is the incompatibility between the gms version in my project and the one used in Onesignal.

I have checked every single solution proposed in these posts:

https://github.com/OneSignal/OneSignal-Android-SDK/issues/286

https://mcmap.net/q/1898687/-android-nosuchmethoderror-no-static-method-zzy-ljava-lang-object/43430478#comment86259725_43430478

Couldn't add OneSignal's Gradle plugin as suggested by OneSignal's official site.

Removing apply plugin: 'com.google.gms.google-services' and classpath 'com.google.gms:google-services:3.2.0' from gradle files will solve this error. But I cannot do it since I want to inflate MapView in my project and I need google-services.

Here is the error I get:

java.lang.NoSuchMethodError: No static method zza(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzbq; or its super classes (declaration of 'com.google.android.gms.common.internal.zzbq' appears in /data/app/com.blah.blah-1/base.apk:classes2.dex)
                      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                      at android.app.ActivityThread.installProvider(ActivityThread.java:6326)
                      at android.app.ActivityThread.installContentProviders(ActivityThread.java:5918)
                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5857)
                      at android.app.ActivityThread.-wrap3(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6682)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

My build.gradle:

apply plugin: 'com.android.application'
android {
        compileSdkVersion 27
        buildToolsVersion '27.0.3'
        defaultConfig
                {
                    applicationId "com.parsdigit.helsa"
                    manifestPlaceholders = [onesignal_app_id               : "4af7b2c1-a1a8-4b4a-ade3-d65289b38267",
                                            // Project number pulled from dashboard, local value is ignored.
                                            onesignal_google_project_number: "REMOTE"]
                    minSdkVersion 21
                    targetSdkVersion 27
                    versionCode 1
                    versionName "1.0"
                    vectorDrawables.useSupportLibrary = true
                    multiDexEnabled true
                }
        buildTypes
                {
                    release
                            {
                                minifyEnabled true
                                shrinkResources true
                                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                                debuggable true
                            }
                }
        aaptOptions {
            cruncherEnabled = false
        }

        packagingOptions
                {
                    exclude 'META-INF/DEPENDENCIES'
                    exclude 'META-INF/LICENSE'
                    exclude 'META-INF/LICENSE.txt'
                    exclude 'META-INF/license.txt'
                    exclude 'META-INF/NOTICE'
                    exclude 'META-INF/NOTICE.txt'
                    exclude 'META-INF/notice.txt'
                    exclude 'META-INF/ASL2.0'
                }

        lintOptions
                {
                    checkReleaseBuilds false
                }
        dexOptions
                {
                    preDexLibraries = false
                    jumboMode true
                    javaMaxHeapSize "4g"
                }
    }
dependencies
    {
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'com.squareup.okhttp3:okhttp:3.+'
        compile 'com.android.support:multidex:1.0.2'
        compile 'com.android.support:design:27.1.0'
        compile 'com.android.support:appcompat-v7:27.1.0'
        compile 'com.google.android.gms:play-services-maps:12.0.0'
        compile 'com.android.support:recyclerview-v7:27.1.0'
        compile 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'
        compile 'org.apache.httpcomponents:httpclient:4.5.4'
        compile 'com.google.maps.android:android-maps-utils:0.4.3'
        compile 'com.google.code.gson:gson:2.8.2'
        compile 'uk.co.chrisjenx:calligraphy:2.2.0'
        compile 'com.pixplicity.easyprefs:library:1.8.1@aar'
        compile 'gun0912.ted:tedpermission:1.0.3'
        compile 'com.kennyc:snackbar:2.5'
        compile 'me.itangqi.waveloadingview:library:0.3.5'
        compile 'com.daimajia.androidanimations:library:2.3@aar'
        compile 'com.fujiyuu75:sequent:0.2.1'
        compile 'pl.charmas.android:android-reactive-location:0.10@aar'
        compile 'io.reactivex:rxjava:1.2.0'
        compile 'me.zhanghai.android.materialratingbar:library:1.2.0'
        compile 'cn.lightsky.infiniteindicator:library:1.2.2'
        compile 'de.hdodenhof:circleimageview:2.2.0'
        compile 'com.github.wooplr:Spotlight:1.2.3'
        compile 'com.caverock:androidsvg:1.2.1'
        compile 'com.github.bumptech.glide:glide:3.8.0'
        compile project(':sidemenulibrary')
        compile('com.github.ozodrukh:CircularReveal:1.1.1@aar') {
            transitive = true;
        }
        compile 'org.greenrobot:eventbus:3.0.0'
        compile 'com.nex3z:notification-badge:0.3.0'
        compile 'com.github.Shashank02051997:FancyGifDialog-Android:1.1'
        compile 'br.com.simplepass:loading-button-android:1.+'
        compile 'com.github.blennerSilva:AwesomeDialog:2.0.5'
        compile 'me.relex:circleindicator:1.2.2@aar'
        compile 'com.airbnb.android:lottie:2.2.5'
        compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
        compile 'com.github.RobertApikyan:SegmentedControl:release_1.0.1'
        compile 'com.github.skydoves:powermenu:2.0.1'
        compile 'com.otaliastudios:cameraview:1.4.1'
        compile 'com.github.Mostafa-MA-Saleh:EditCredit:1.5.0'
        compile 'com.github.mreram:ShowCaseView:1.0.5'
        compile 'com.mohamadamin:persianmaterialdatetimepicker:1.2.1'
        compile 'com.alirezaafkar:sundatepicker:2.0.8'
        compile('com.cedarmaps:CedarMapsSDK:2.0.0@aar') {
            transitive = true
        }
    }
afterEvaluate
    {
        tasks.matching
        {
            it.name.startsWith('dex')
        }
        .each
                { dx ->
                    if (dx.additionalParameters == null) {
                        dx.additionalParameters = ['--multi-dex']
                    } else {
                        dx.additionalParameters += '--multi-dex'
                    }
                }
    }

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

My toplevel build.gradle:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.google.gms:google-services:3.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        maven { url "http://repo.cedarmaps.com/android/" }
        jcenter()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        maven { url 'https://dl.bintray.com/kennyc1012/maven' }
        maven { url "http://dl.bintray.com/glomadrian/maven" }
        maven { url "https://maven.google.com" }
        google()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
Shahjahanpur answered 4/4, 2018 at 7:31 Comment(0)
S
1

POOOH! After struggling for a long couple of hours finally fixed the issue by:

changing classpath 'com.google.gms:google-services:3.2.0' to classpath 'com.google.gms:google-services:3.2.1'

and updating implementation 'com.google.android.gms:play-services-maps:12.0.0' to implementation 'com.google.android.gms:play-services-maps:12.0.1'

Shahjahanpur answered 4/4, 2018 at 9:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.