简体   繁体   中英

Didn't find class “com.google.android.gms.common.util.zzs”

Frist, I have a module in a large project I try to upgrade it to use the latest version of Gradle and libraries I used api instead of implementation because I need to use some liberties in the project and module after the upgradation the Application crash when receiving a notification from firebase. I try to update FCM to the latest version and also gms location for the latest version it's worked before update Gradle, FCM and GMS the version I used before was 12.0.1 and my application wasn't crash

apply plugin: 'com.android.library'
apply plugin: 'realm-android'

android {
    compileSdkVersion rootProject.compileSdkVersion
    buildToolsVersion rootProject.buildToolsVersion


    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

    repositories {
        flatDir {
            dirs 'libs'

        }
    }

}

ext {
    appCompatVersion = '27.1.1'
    rxJavaVersion = '1.1.1'
    rxAndroidVersion = '0.24.0'
    constraintLayoutVersion = '1.1.1'
    glideVersion = '3.7.0'
    shortcutBadgerVersion = '1.1.16@aar'
    fabVersion = '1.6.4'
    libphoneGeocoderVersion = '2.62'
    libphoneVersion = '8.2.0'
    retrofitVersion = '2.3.0'
    countryPickerVersion = '1.1.9'
    webSocketVersion = '1.3.0'
    webRtcVersion = '9127@aar'
    firebaseVersion = '17.0.0'
    okHttpVersion = '3.8.1'
    hockeyAppVersion = '5.1.0'
    exoPlayerVersion = '2.6.0'
    eventBusVersion = '3.1.1'
    gmsVersion='15.0.1'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    api "com.android.support:appcompat-v7:$appCompatVersion"
    api "com.android.support:design:$appCompatVersion"
    api "io.reactivex:rxjava:$rxJavaVersion"
    api "io.reactivex:rxandroid:$rxAndroidVersion"
    api "com.android.support.constraint:constraint-layout:$constraintLayoutVersion"
    api "com.github.bumptech.glide:glide:$glideVersion"
    api "me.leolin:ShortcutBadger:$shortcutBadgerVersion"
    api "com.github.clans:fab:$fabVersion"
    api "com.googlecode.libphonenumber:geocoder:$libphoneGeocoderVersion"
    api "com.googlecode.libphonenumber:libphonenumber:$libphoneVersion"
    api "com.squareup.retrofit2:retrofit:$retrofitVersion"
    api "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    api "com.github.mukeshsolanki:country-picker-android:$countryPickerVersion"
    api "org.java-websocket:Java-WebSocket:$webSocketVersion"
    api "io.pristine:libjingle:$webRtcVersion"
    implementation "com.google.firebase:firebase-messaging:$firebaseVersion"
    api "com.squareup.okhttp3:okhttp:$okHttpVersion"
    api "net.hockeyapp.android:HockeySDK:$hockeyAppVersion"
    api "org.greenrobot:eventbus:$eventBusVersion"
    api ("com.google.android.gms:play-services-location:$gmsVersion"){
        force = true
    }
    api('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true
    }
    api('com.crashlytics.sdk.android:answers:1.4.1@aar') {
        transitive = true
    }

    //excluding annotations dependency as it conflicts with that of dialer in the version
    api("com.google.android.exoplayer:exoplayer-core:$exoPlayerVersion") {
        exclude group: 'com.android.support', module: 'support-annotations'
    }

    api(name: 'lifbeandroidlib-1.0.1', ext: 'aar')
    api(name: 'networkcollectdata-1.8.0', ext: 'aar')

    //test
    testImplementation 'junit:junit:4.12'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    api group: 'com.squareup.leakcanary', name: 'leakcanary-android', version: '1.5.1'
}

and this error log

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzs;
        at com.google.android.gms.gcm.GcmReceiver.onReceive(Unknown Source)
        at android.app.ActivityThread.handleReceiver(ActivityThread.java:3104)
        at android.app.ActivityThread.-wrap18(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:241)
        at android.app.ActivityThread.main(ActivityThread.java:6274)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.util.zzs" on path: DexPathList[[zip file

Update your play-services dependency -

com.google.android.gms:play-services-base:15.0.1

Firebase needs the base play services library to function properly.

After a lot of circus, I found out the issue, During the migration of App from GCM to FCM, we have to remove the "Receiver" from AndroidManifest.xml.

Receiver to be Removed:

<receiver
     android:name="com.google.android.gms.gcm.GcmReceiver"
     android:exported="true"
     android:permission="com.google.android.c2dm.permission.SEND">
     <intent-filter>
         <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
         <category android:name="com.gnirt69.gcmexample"/>
     </intent-filter>
 </receiver>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM