Closed nguyenbahung94 closed 4 years ago
Please provide full log from logcat and add more information on which step you get this error (login to the chat or load messages or another ways).
Please provide full log from logcat and add more information on which step you get this error (login to the chat or load messages or another ways).
Sorry about that 1.I have an issue at screen load messages. in class ChatMessageListViewModel. it always return null .
fun getChatDialog(dialogId: String = this.dialogId): LiveData<Resource
val source = chatRepository.getChat(dialogId)
result.addSource(source) { chatDialog ->
if (chatDialog == null) {
result.value = Resource.error(
getApplication<Application>().getString(R.string.something_went_wrong_try_again_later),
null
)
} else {
result.value = Resource.success(chatDialog)
}
result.removeSource(source)
}
return result
}
2.If in screen ChatMessageActivity I type some characters and press send the app will be crash.
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.connectycube.messenger, PID: 19486 java.lang.IllegalStateException: Could not execute method for android:onClick at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:402) at android.view.View.performClick(View.java:7161) at android.view.View.performClickInternal(View.java:7138) at android.view.View.access$3500(View.java:811) at android.view.View$PerformClick.run(View.java:27419) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7520) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:397) at android.view.View.performClick(View.java:7161) at android.view.View.performClickInternal(View.java:7138) at android.view.View.access$3500(View.java:811) at android.view.View$PerformClick.run(View.java:27419) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7520) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) Caused by: kotlin.UninitializedPropertyAccessException: lateinit property modelMessageSender has not been initialized at com.connectycube.messenger.ChatMessageActivity.sendChatMessage(ChatMessageActivity.kt:480) at com.connectycube.messenger.ChatMessageActivity.onSendChatClick(ChatMessageActivity.kt:450) at java.lang.reflect.Method.invoke(Native Method) at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:397) at android.view.View.performClick(View.java:7161) at android.view.View.performClickInternal(View.java:7138) at android.view.View.access$3500(View.java:811) at android.view.View$PerformClick.run(View.java:27419) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7520) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) E/MQSEventManagerDelegate: failed to get MQSService.
You can test this case by these information :
private val applicationID = "2631"
private val authKey = "dSmHvdrdgZstryr"
private val authSecret = "jtnyXeZABwgRVR3"
private val accountKey = "wsSEhzAJEGkL66N4mBiF"
in logs I found next line 'Caused by: kotlin.UninitializedPropertyAccessException: lateinit property modelMessageSender has not been initialized'. Please check if you initialise field modelMessageSender
in your ChatMessageActivity
class before send message.
in logs I found next line 'Caused by: kotlin.UninitializedPropertyAccessException: lateinit property modelMessageSender has not been initialized'. Please check if you initialise field
modelMessageSender
in yourChatMessageActivity
class before send message.
1, I see, But I want to know why the input when start ChatMessageActivity is an instance of ConnectycubeChatDialog, then I pass that object but the code did not work well as your example.
How I can fix this? I want to use it to make a real app. I really need solution for these case, Could you answer me soon?
We need FULL log to investigate behavoir of your app logic. I asked this information in my previous comments, but you provided only stacktrace of error. From provided information we can't understand did you send message or not, did sender receive message status package or not, etc. I think this issue related with your new logic, but without asked information we can't help you.
We need FULL log to investigate behavoir of your app logic. I asked this information in my previous comments, but you provided only stacktrace of error. From provided information we can't understand did you send message or not, did sender receive message status package or not, etc. I think this issue related with your new logic, but without asked information we can't help you.
Can you check out this link: https://drive.google.com/file/d/1LdRHn5XIglWWiCncCi9bYMQSa-V8MUBS/view?usp=sharing Please download the project and run, When you login with different user (I already set two user in the project) and chat you will understand. Thank you for your response to me soon.
today I built your app and tested. After first start of app behavior looks like normal, but when I clicked back button I receive behavoir like you described before. After fast review your code I found next part
ConnectycubeRestChatService.createChatDialog(dialog)
.performAsync(object : EntityCallback<ConnectycubeChatDialog> {
override fun onSuccess(createdDialog: ConnectycubeChatDialog, params: Bundle) {
// startChatActivity(createdDialog)
chatDialogListViewModel.createNewChatDialog(createdDialog)
why you call chatDialogListViewModel.createNewChatDialog
in success block of request ConnectycubeRestChatService.createChatDialog
? As result you call same request again, because method chatDialogListViewModel.createNewChatDialog
calls ConnectycubeRestChatService.createChatDialog
inside.
If you see logs, you will found new request for dialog creation with next parameters:
name=null
occupants_ids=1479801,1479875
type=3
As result you get new dialog with name 'null'. Then you asked messages for this dialog and receive empty list, it is expected behavior, because you don't have any messages in new dialog.
Please review your code and fix not clear behavior of your app .
today I built your app and tested. After first start of app behavior looks like normal, but when I clicked back button I receive behavoir like you described before. After fast review your code I found next part
ConnectycubeRestChatService.createChatDialog(dialog) .performAsync(object : EntityCallback<ConnectycubeChatDialog> { override fun onSuccess(createdDialog: ConnectycubeChatDialog, params: Bundle) { // startChatActivity(createdDialog) chatDialogListViewModel.createNewChatDialog(createdDialog)
why you call
chatDialogListViewModel.createNewChatDialog
in success block of requestConnectycubeRestChatService.createChatDialog
? As result you call same request again, because methodchatDialogListViewModel.createNewChatDialog
callsConnectycubeRestChatService.createChatDialog
inside.If you see logs, you will found new request for dialog creation with next parameters:
name=null occupants_ids=1479801,1479875 type=3
As result you get new dialog with name 'null'. Then you asked messages for this dialog and receive empty list, it is expected behavior, because you don't have any messages in new dialog.
Please review your code and fix not clear behavior of your app .
I was my bad I'm so sorry about that. I was check and write new code to make it more clear about my issue. Please help me check out this link : https://drive.google.com/file/d/1z8MIiRLtEZKgXOhGop3o_tDvM10VjHGS/view?usp=sharing
When you run a project you will get a message "Error while loading users" But don't pay attention to that. The issue I was mentioned here is the message I sent it not synchronized. When I reinstall and log in again the message synchronized, like the first message in the picture below.
now I can't reproduce issue from yesterday, what help you need now?
now I can't reproduce issue from yesterday, what help you need now?
Like I said before the I still receive the message but it does not have two icons check blue at the bottom of the message. When I'm chatting, Could you try function chat on two devices, you will more understanding.
I run the app on two devices at the same time and chat but the message still not have two blue sticks at the bottom of the message. Like the picture below
As you can see in our sample ChatMessagesStatusListener
initialises in ChatDialogActivity
, but in your code you don't use this activity, it is because you don't get statuses of messages. You can move needed logic from ChatDialogActivity
to ChatMessageActivity
but pay attention what and how you do in your code.
As you can see in our sample
ChatMessagesStatusListener
initialises inChatDialogActivity
, but in your code you don't use this activity, it is because you don't get statuses of messages. You can move needed logic fromChatDialogActivity
toChatMessageActivity
but pay attention what and how you do in your code.
Finally, I'm done with this issue, Thank you for spending time to support me. Thank you so much and Have a nice day,
Hi, I want to login by these steps and base on your example.
I replace method login in LoginActivity by this:
var user1 = ConnectycubeUser() user1.login = "hung1" user1.password = "password1"
////////////////////// private fun createChatPrivate(id: Int) { val occupantIds = ArrayList()
occupantIds.add(id)
////////// private fun startChatActivity(chat: ConnectycubeChatDialog) { val intent = Intent(this@LoginActivity, ChatMessageActivity::class.java) intent.putExtra(EXTRA_CHAT, chat) startActivity(intent) }
You should uninstall the app before test this. I got an issue for a few days and I hope you can help me fix this. Thanks,