ibm-bluemix-mobile-services / bms-clientsdk-android-push

Android Push notifications SDK for IBM Cloud Mobile Services
Apache License 2.0
10 stars 12 forks source link

After killing the app, when the push notification is received, the app crashes. #134

Closed PacteraZhangTong closed 4 years ago

PacteraZhangTong commented 4 years ago

After killing the app, when the push notification is received, the app crashes.

build.gradle: api 'com.ibm.mobilefirstplatform.clientsdk.android:core:3.1.7' api (group: 'com.ibm.mobilefirstplatform.clientsdk.android', name: 'push', version: '4.2.1', ext: 'aar', transitive: false){ exclude group: 'com.google.code.gson', module: 'gson' }

Log: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationCompat$Builder; at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.generateNotification(MFPPushIntentService.java:304) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onUnhandled(MFPPushIntentService.java:235) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onNotificationReceived(MFPPushIntentService.java:198) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onMessageReceived(MFPPushIntentService.java:137) at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source) at com.google.firebase.iid.zzc.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.NotificationCompat$Builder" on path: DexPathList[[zip file "/data/app/jp.co.hiroshimabank.securestarter.stg-1/base.apk"],nativeLibraryDirectories=[/data/app/jp.co.hiroshimabank.securestarter.stg-1/lib/arm64, /data/app/jp.co.hiroshimabank.securestarter.stg-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.generateNotification(MFPPushIntentService.java:304) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onUnhandled(MFPPushIntentService.java:235) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onNotificationReceived(MFPPushIntentService.java:198) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onMessageReceived(MFPPushIntentService.java:137) at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source) at com.google.firebase.iid.zzc.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source) at java.lang.Thread.run(Thread.java:818) Suppressed: java.lang.ClassNotFoundException: androidx.core.app.NotificationCompat$Builder at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

The log says: Failed resolution of: Landroidx / core / app / NotificationCompat $ Builder

How can i solve this problem?

AnanthaKrish commented 4 years ago

@PacteraZhangTong What is the device android version ?

PacteraZhangTong commented 4 years ago

@AnanthaKrish I've used Android 8.0 and 9.0, which all have this problem

AnanthaKrish commented 4 years ago

@PacteraZhangTong What is the build version in your gradle ? Please use 26 or above.

PacteraZhangTong commented 4 years ago

@AnanthaKrish I've used compileSdkVersion 28

build.gradle: compileSdkVersion 28 defaultConfig { minSdkVersion 23 targetSdkVersion 28 }

AnanthaKrish commented 4 years ago

@PacteraZhangTong The failure is when a data notification comes, then push SDK try to build a notification from that . Check this line 284. From API 26 the NotificationCompat.Builder(context) is deprecated , so we have to check that condition . Somehow in your app the condition showing its below 26 , and goes to the line number 304, and it cannot find it.

I think this can be fixed from build.gradle. Please check your appcompat version as well.

I have tested the app with this

    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.google.firebase:firebase-messaging:20.0.0'

and


     classpath 'com.android.tools.build:gradle:3.5.2'
     classpath 'com.google.gms:google-services:4.3.3'
PacteraZhangTong commented 4 years ago

Sorry, I just made a mistake. The error log above is Android 6 Device printed, using Android9.0 The following exception was thrown:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationCompat$Builder; at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.generateNotification(MFPPushIntentService.java:299) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onUnhandled(MFPPushIntentService.java:235) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onNotificationReceived(MFPPushIntentService.java:198) at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.onMessageReceived(MFPPushIntentService.java:137) at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source:60) at com.google.firebase.iid.zzg.run(Unknown Source:4) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6) at java.lang.Thread.run(Thread.java:764)

Is this problem related to Androidx?

AnanthaKrish commented 4 years ago

@PacteraZhangTong Looks like it is.

PacteraZhangTong commented 4 years ago

My project has not been upgraded to AndroidX, I will upgrade it to Androidx later,and try to solve this problem。

AnanthaKrish commented 4 years ago

@PacteraZhangTong Sure. Please let us know.

PacteraZhangTong commented 4 years ago

Thank you very much for your answer. After I upgraded the project to Android x, this problem has been solved