I have integrated Quick Blox Chat SDK version 3.8.1 (the latest version available as on 25-Sep-2018). I have successfully integrated the chat SDK. The problem which I'm facing is app crashes while opening for the first time with the following error.
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
at com.google.android.gms.gcm.Task$Builder.checkConditions(Unknown Source:10)
at com.google.android.gms.gcm.OneoffTask$Builder.checkConditions(Unknown Source:0)
at com.google.android.gms.gcm.OneoffTask$Builder.build(Unknown Source:0)
at com.quickblox.messages.services.SubscribeTaskManager.a(Unknown Source:49)
at com.quickblox.messages.services.SubscribeService.c(Unknown Source:22)
at com.quickblox.messages.services.SubscribeService.a(Unknown Source:145)
at com.quickblox.messages.services.SubscribeService.a(Unknown Source:125)
at com.quickblox.messages.services.SubscribeService.e(Unknown Source:12)
at com.quickblox.messages.services.SubscribeService.b(Unknown Source:18)
at com.quickblox.messages.services.SubscribeService.onHandleWork(Unknown Source:46)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:392)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:383)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/-HWe3wDorvDDaXln_aZyI2g==/base.apk"],nativeLibraryDirectories=[/data/app/HWe3wDorvDDaXln_aZyI2g==/lib/x86, /data/app/HWe3wDorvDDaXln_aZyI2g==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.android.gms.gcm.Task$Builder.checkConditions(Unknown Source:10)
at com.google.android.gms.gcm.OneoffTask$Builder.checkConditions(Unknown Source:0)
at com.google.android.gms.gcm.OneoffTask$Builder.build(Unknown Source:0)
at com.quickblox.messages.services.SubscribeTaskManager.a(Unknown Source:49)
at com.quickblox.messages.services.SubscribeService.c(Unknown Source:22)
at com.quickblox.messages.services.SubscribeService.a(Unknown Source:145)
at com.quickblox.messages.services.SubscribeService.a(Unknown Source:125)
at com.quickblox.messages.services.SubscribeService.e(Unknown Source:12)
at com.quickblox.messages.services.SubscribeService.b(Unknown Source:18)
at com.quickblox.messages.services.SubscribeService.onHandleWork(Unknown Source:46)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:392)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:383)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
The app were working fine without any issue prior to integrate chat SDK. So I'm strongly belive that the issue is caused by chat SDK.
Notes
Mutidex is already enabled
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' }
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp"
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0 - Alpha Dev version"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
def paging_version = "1.0.1"
def material = "1.0.0-rc01"
def qbSdkVersion = '3.8.1'
def swipyVersion = '1.2.3'
def stickylistheadersVersion = '0.4.2'
def androidSupport = '28.0.0'
def androidArch = '1.1.1'
def playService = '15.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$androidSupport"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:design:$androidSupport"
implementation 'com.google.firebase:firebase-crash:16.2.0'
implementation "android.arch.lifecycle:extensions:$androidArch"
implementation "android.arch.lifecycle:viewmodel:$androidArch"
implementation "android.arch.persistence.room:runtime:$androidArch"
annotationProcessor "android.arch.persistence.room:compiler:$androidArch"
implementation "com.google.android.gms:play-services-location:$playService"
implementation "com.google.android.gms:play-services-places:$playService"
implementation "com.google.firebase:firebase-core:16.0.3"
implementation 'com.google.firebase:firebase-messaging:17.3.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.daimajia.slider:library:1.1.5@aar'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'pub.devrel:easypermissions:1.2.0' /*permission simplified*/
implementation 'com.github.jrvansuita:PickImage:2.2.3'/*Image picker Camera/Gallery*/
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0' /*Image cropper*/
implementation 'com.wdullaer:materialdatetimepicker:3.6.3' /*Date picker*/
implementation 'com.kofigyan.stateprogressbar:stateprogressbar:1.0.0'
implementation('com.github.ganfra:material-spinner:2.0.0') {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation 'com.github.danimahardhika:cafebar:1.3.1'/*Snack Toast SDK*/
implementation(name: 'sinch-android-verification-1.5.1', ext: 'aar') /*SMS verification*/
implementation 'com.github.blocoio:faker:1.2.7' /*Data faker*/
implementation 'com.github.joielechong:countrycodepicker:2.1.8'
implementation 'com.yarolegovich:sliding-root-nav:1.1.0' /*Custom nav drawer*/
implementation "com.yuyakaido.android:card-stack-view:1.0.0-beta9" /*Card stack view*/
implementation 'com.jaredrummler:android-animations:1.0.0' /*View Animator*/
implementation 'com.facebook.fresco:fresco:1.10.0'
implementation 'com.github.Binary-Finery:Bungee:master-SNAPSHOT'/*Activity Translation*/
implementation 'com.github.ybq:Android-SpinKit:1.1.0' /*Loading animations*/
implementation 'com.github.thunder413:DateTimeUtils:1.0' /*Date converter utility*/
implementation(name: 'filepicker', ext: 'aar')
implementation(name: 'materialrangebar', ext: 'aar')
implementation 'com.github.warkiz.widget:indicatorseekbar:2.0.9'
implementation 'com.github.PuffoCyano:Range-Time-Picker-Dialog:v1.5' /*Multi time range picker*/
implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
transitive = true;
}
implementation "com.quickblox:quickblox-android-sdk-chat:$qbSdkVersion"
implementation "com.quickblox:quickblox-android-sdk-extensions:$qbSdkVersion"
implementation "com.quickblox:quickblox-android-sdk-messages:$qbSdkVersion"
implementation 'com.quickblox:chat-message-adapter:2.0'
implementation "com.github.orangegangsters:swipy:$swipyVersion@aar"
implementation "com.timehop.stickyheadersrecyclerview:library:$stickylistheadersVersion@aar"
}
apply plugin: 'com.google.gms.google-services'
Let me explain the scenario where app crash.
Any help appreciated.
Since version 3.2 android SDK provides new feature - auto subscription to push notification out of the box. It means you don’t need bother how to get GCM or FCM token, create QBPushNotifications.createSubscription and what to do with received data in your code anymore.
Actually what's making the app crash is that, you have not added the GCM dependency as stated by Quickblox. Add the GCM dependency with version same as your other play services sdk version:
implementation "com.google.android.gms:play-services-gcm:$your_version"
This will remove Caused by: java.lang.NoClassDefFoundError