IllegalAccess:: com.sendbird.androidAbstractPushHandler.AbstractPushHandler

I can’t register MyMessagingService extending SendBirdPushHandler.

import kr.co.batontouch.workout.PushUtils
PushUtils.registerPushHandler(MyMessagingService())

Illegal class access error:

java.lang.IllegalAccessError: Illegal class access: 'kr.co.batontouch.workout.PushUtils' attempting to access 'com.sendbird.android.AbstractPushHandler' (declaration of 'kr.co.batontouch.workout.PushUtils' appears in /data/app/kr.co.batontouch.workout.inhouse-Ds_nRUJZO0FYGD8iJqAoeg==/base.apk!classes2.dex)

I thought this error occurs for multidex files. so I added multidex-config.txt and tested. But failed.

kr/co/batontouch/workout/PushUtils.class

This works well if I create PushUtils in com.sendbird.android package.

import com.sendbird.android.PushUtil
PushUtils.registerPushHandler(MyMessagingService())

I think this error occurs because AbstractPushHandler is package private class.

Hi @brownsoo,

You are correct in that the AbstractPushHandler is private:

Check out the Chat Sample from this repo on an option for wrapping the SendBird PushHelper functions. Image of a PushUtils class in that project:

Thanks @Jason_Koo.
I used that ways in our project.

SendBirdPushHandler, SendBirdPushHelper are not part of UIKit library?
PushUtils is a part of UIKit example app.

so, I thought the code below can be able to work in app module.

// kotlin code
SendBirdPushHelper.registerPushHandler(MyFirebaseMessagingService());

I think the more detailed guide should be exists in Multi-device support page

thank you.

Yup, both classes are in the chat SDK which is pulled in with UIKit. So both

import com.sendbird.android.SendBirdPushHelper
import com.sendbird.android.SendBirdPushHandler

will work. Are you saying the illegalAccessError occurs when running

SendBirdPushHelper.registerPushHandler(MyFirebaseMessagingService()); directly?

Yes, I also think it’s weird.

kr.co.batontouch.workout.support.PushUtils occurs the error below. If I moved the class to com.sendbird.android.PushUtils, than it works ok.

2021-01-11 12:39:44.245 6094-6094/kr.co.batontouch.workout.inhouse E/AndroidRuntime: FATAL EXCEPTION: main
Process: kr.co.batontouch.workout.inhouse, PID: 6094
java.lang.IllegalAccessError: Illegal class access: 'kr.co.batontouch.workout.support.PushUtils' attempting to access 'com.sendbird.android.AbstractPushHandler' (declaration of 'kr.co.batontouch.workout.support.PushUtils' appears in /data/app/kr.co.batontouch.workout.inhouse-ohSOvVRVmFva6EQQKN8h5Q==/base.apk!classes2.dex)
    at kr.co.batontouch.workout.support.PushUtils.registerPushHandler(PushUtils.kt:12)
    at kr.co.batontouch.workout.support.SendBirdCenter.initWith(SendBirdCenter.kt:61)
    at kr.co.batontouch.workout.MyApplication.onCreate(MyApplication.kt:51)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
    at android.app.ActivityThread.access$1300(ActivityThread.java:219)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Are you able to put some of the same code into a sample project to try and help debug the issue from?

This error do not occurs in UIKit sample app, so I am try to struggle this issue in our project.

I will replay later.