OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
604 stars 368 forks source link

java.lang.NoSuchMethodError: No static method zzb #286

Closed Bekakk closed 6 years ago

Bekakk commented 7 years ago

Hi I'm using your repo.I successfully integrated OneSignal Sdk in my empty project.But I have one problem,now I try to add com.google.gsm.google-services in my project.Here is one gradlie file

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

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

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

Here is a project's gradlie file

apply plugin: 'com.android.application'

android {

    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "*********"

        manifestPlaceholders = [onesignal_app_id: "my app ID",
                                onesignal_google_project_number: "REMOTE"]
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 20
        versionName "1.0.20"
        testInstrumentationRunner "android.support.buy_tickets_verification_view.runner.AndroidJUnitRunner"
        renderscriptSupportModeEnabled true
        multiDexEnabled true

        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.config
            minifyEnabled false
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.android.support:support-vector-drawable:25.3.1') {
        force = true;
    }
    compile files('libs/junit-4.12.jar')

    compile 'com.google.android.gms:play-services-gcm:10.2.4'

    compile 'com.google.android.gms:play-services-location:10.2.4'

    compile files('libs/volley.jar')
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.android.support:support-annotations:25.0.0'
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:cardview-v7:25.0.0'

    compile 'com.google.firebase:firebase-messaging:10.2.4'

    compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)'

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

When i ran my app I have this Exception

java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
in class Lcom/google/android/gms/common/internal/zzac;
or its super classes (declaration of 'com.google.android.gms.common.internal.zzac' appears in /data/app/com.myproject.android-1/base.apk:classes12.dex)

How i can solve my problem? Thanks everyone Beka

jkasten2 commented 7 years ago

@Bekakk Can you remove classpath 'com.google.gms:google-services:3.0.0' from your root build.gradle and apply plugin: 'com.google.gms.google-services' from your app/build.gradle? These are know to cause conflicts due to version mixing with other compile 'com.google.android.gms:*' lines. https://documentation.onesignal.com/docs/troubleshooting-android#section-error-execution-failed-for-task-app-processdebuggoogleservices-

pzienowicz commented 7 years ago

Hi @jkasten2, I have the same issue.

Main gradle file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

App gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '25.0.2'

    defaultConfig {
        applicationId "XXX"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 15
        versionName "2.0.0"

        manifestPlaceholders = [onesignal_app_id: "XXX",
                                onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.android.support:gridlayout-v7:26.0.2'
    compile 'org.ocpsoft.prettytime:prettytime:3.2.7.Final'
    compile 'com.yarolegovich:lovely-dialog:1.0.4'
    compile 'com.android.support:cardview-v7:26.0.2'
    compile 'com.android.support:recyclerview-v7:26.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'me.gujun.android.taggroup:library:1.4@aar'
    compile 'ch.acra:acra:4.9.2'
    compile 'com.anjlab.android.iab.v3:library:1.0.44'
    compile 'com.google.firebase:firebase-core:11.0.4'

    compile 'com.onesignal:OneSignal:3.6.0'
    compile 'com.squareup.assertj:assertj-android:1.1.1'
    testCompile 'junit:junit:4.12'
}

Please help, when added your dependency - app crashes immediately after start.

pzienowicz commented 7 years ago

@jkasten2 any idea? I am not able to use your SDK.

jkasten2 commented 7 years ago

@pzienowicz There could be a mismatch between 'com.google.firebase and com.google.android.gms versions in your project. gms 11.2.0 will be used by the OneSignal SDK so you will need to update com.google.firebase:firebase-core to 11.2.0 as well. See this error for more details. https://documentation.onesignal.com/docs/troubleshooting-android#section-error-all-gms-firesbase-libraries-must-use-the-exact-same-version-specification

If you are still getting a crash please attach the full stack trace.

Daemon-Devarshi commented 7 years ago

Hi @jkasten2 ,

I am facing same problem due to which I am unable to use your SDK.

Below is the full stack trace:

java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzbp; or its super classes (declaration of 'com.google.android.gms.common.internal.zzbp' appears in /data/app/stack.myapp-2/base.apk)
                                                                        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                                                                        at android.app.ActivityThread.installProvider(ActivityThread.java:5852)
                                                                        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5444)
                                                                        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5383)
                                                                        at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:154)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6123)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

Here is my App gradle file:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

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

android {
    compileSdkVersion 26
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "stack.myapp"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 30
        versionName "1.3"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        jackOptions {
            enabled true
        }
        manifestPlaceholders = [onesignal_app_id: "my app id",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "my project number"]
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.google.android.gms:play-services-analytics:11.2.2'
    compile 'com.google.firebase:firebase-messaging:11.2.2'
    compile 'com.google.firebase:firebase-core:11.2.2'
    compile 'com.google.firebase:firebase-invites:11.2.2'
    compile 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'

    testCompile 'junit:junit:4.12'

    // butterknife configuration
    compile 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

    // apt command comes from the android-apt plugin
    annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
    compile 'com.google.dagger:dagger:2.7'
    provided 'javax.annotation:jsr250-api:1.0'

    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.truizlop.sectionedrecyclerview:library:1.2.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true
    }
}

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

Here is the module build.gradle:

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.google.gms:google-services:3.1.0'

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

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

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

Please suggest.

007law commented 7 years ago

my project is using firebase and one signal together, but I was faced the problem of java.lang.NoSuchMethod as OP too.. after I keep on trying on everything, I solved my problem, below is my gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "project.myproject.project"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        defaultConfig {
            manifestPlaceholders = [onesignal_app_id: "my ID",
                                    // Project number pulled from dashboard, local value is ignored.
                                    onesignal_google_project_number: "REMOTE"]
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            res.srcDirs =
                    [
                            'src/main/res/layout/Delivery',
                            'src/main/res/layout/Item',
                            'src/main/res/layout/Login',
                            'src/main/res/layout/Overnight',
                            'src/main/res/layout/Profile',
                            'src/main/res/layout/Transfer',
                            'src/main/res'
                    ]
        }
    }
}
repositories {
    maven { url 'https://maven.google.com' }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-core:11.4.2'
    compile 'com.google.firebase:firebase-auth:11.4.2'
    compile 'com.google.firebase:firebase-storage:11.4.2'
    compile 'com.google.firebase:firebase-config:11.4.2'
    compile 'com.google.firebase:firebase-database:11.4.2'
    compile 'com.google.firebase:firebase-messaging:11.4.2'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
    compile 'com.google.android.gms:play-services-gcm:11.4.2'
    compile 'com.google.android.gms:play-services-location:11.4.2'
}
apply plugin: 'com.google.gms.google-services'

I just update every library dependencies to latest version hope it can help

cbedoy commented 7 years ago

Also I have the same issue.

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'me.tatarka.retrolambda'

android {
    compileSdkVersion 26
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.xxx"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 280
        versionName "0.28" //based on backend modules
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled  true

        manifestPlaceholders = [onesignal_app_id: "app_id",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]
    }

    buildTypes {
        release {
            applicationIdSuffix ".native"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

             }

        dagteam{
            applicationIdSuffix ".dagteam"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }

        debug{
            applicationIdSuffix ".dagdev"
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            testCoverageEnabled true

        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dexOptions {
        jumboMode = true
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

    lintOptions {
        checkReleaseBuilds false
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}

ext {
    supportLibVersion = "26.1.0"
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile "com.android.support:recyclerview-v7:${supportLibVersion}"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.ogaclejapan.smarttablayout:library:1.2.1@aar'
    compile 'org.nibor.autolink:autolink:0.6.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.github.fafaldo:fab-toolbar:1.2.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.6.3'
    compile 'it.sephiroth.android.library.imagezoom:imagezoom:2.2.5'
    compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'net.danlew:android.joda:2.9.9'

    compile 'com.github.jkwiecien:EasyImage:2.0.3'
    compile 'com.github.bumptech.glide:glide:3.8.0'
    compile 'jp.wasabeef:glide-transformations:2.0.2'
    // If you want to use the GPU Filters
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'

    //For xmpp
    compile "org.igniterealtime.smack:smack-android:4.2.0"
    compile "org.igniterealtime.smack:smack-tcp:4.2.0"
    compile "org.igniterealtime.smack:smack-im:4.2.0"
    compile "org.igniterealtime.smack:smack-extensions:4.2.0"

    //Crash reports
    compile 'com.instabug.library:instabug:4.3.0'

    //For Dagger
    compile 'com.google.dagger:dagger:2.11'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
    provided 'org.glassfish:javax.annotation:10.0-b28'

    //Butterknife
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    //Testing

    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    testCompile "org.powermock:powermock-module-junit4:1.6.2"
    testCompile "org.powermock:powermock-module-junit4-rule:1.6.2"
    testCompile "org.powermock:powermock-api-mockito:1.6.2"
    testCompile "org.powermock:powermock-classloading-xstream:1.6.2"

    //Android Testing
    androidTestCompile "junit:junit:$rootProject.ext.junitVersion"
    androidTestCompile "org.mockito:mockito-core:$rootProject.ext.mockitoVersion"
    androidTestCompile "com.google.dexmaker:dexmaker:$rootProject.ext.dexMakerVersion"
    androidTestCompile "com.google.dexmaker:dexmaker-mockito:$rootProject.ext.dexMakerVersion"
    androidTestCompile("com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion", {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestCompile("com.android.support.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion") {
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.android.support', module: 'design'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude module: 'recyclerview-v7'
    }

    //compile 'com.kbeanie:multipicker:1.1.31@aar'
    compile 'com.linchaolong.android:imagepicker:1.5'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.droidninja:filepicker:2.0.8'

    compile("com.github.hotchemi:permissionsdispatcher:2.4.0") {
        // if you don't use android.app.Fragment you can exclude support for them
        exclude module: "support-v13"
    }
    annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:2.4.0"

    compile 'com.google.firebase:firebase-core:10.2.6'
    compile 'com.google.firebase:firebase-messaging:10.2.6'
    compile 'com.github.stfalcon:frescoimageviewer:0.5.0'
    compile "com.facebook.fresco:fresco:1.2.0"

    compile "com.fasterxml.jackson.core:jackson-core:2.7.4"
    compile "com.fasterxml.jackson.core:jackson-databind:2.7.4"
    compile "com.github.tony19:named-regexp:0.2.4"

    compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.4@aar') {
        transitive = true
    }

    compile ('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0@aar'){
        transitive=true
    }

    compile('com.mikepenz:aboutlibraries:5.9.7@aar') {
        transitive = true
    }

    compile 'com.onesignal:OneSignal:[3.5.8, 3.9.9]'

}
apply plugin: 'com.google.gms.google-services'
cbedoy commented 7 years ago

I found the solution, think I did a frankestein and it works! At least for me, if you want can see my last comment over this https://github.com/OneSignal/OneSignal-Android-SDK/issues/327

No more runtime crash

pencilcheck commented 7 years ago

This works for me

  compile 'com.google.android.gms:play-services:+'
  compile 'com.google.firebase:firebase-core:+'
jkasten2 commented 7 years ago

We just released a beta Gradle plugin that will align versions of dependencies which should resolve the errors noted on this thread automatically. https://github.com/OneSignal/OneSignal-Gradle-Plugin

If this resolves your issues please attach your original error and build.gradle so we know which libraries and versions this helps solve.

If the plugin does not solve your issue please open a new issues below with the same details so it can be addressed in this plugin. https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues

apurvaaggarwal commented 6 years ago

007law thanks . It worked for me update all library versions and gms version as well . It will definitely work. Make sure all google services library you are using must be of same version

Khoonat commented 6 years ago

@jkasten2 Your suggestion works. But if I remove them, I won't be able to inflate the map view.

jkasten2 commented 6 years ago

@Khoonat Could you share the Java code that no longer working in your app after adding the OneSignal-Gradle-Plugin? You can open ticket below filling out the template so we can look into it https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/new

jkasten2 commented 6 years ago

@ronayumik No need to add them manually to your build.gradle. They are added automatically when you add OneSignal. Since OneSignal has defined Firebase Messaging as a dependency.