Unable to find explicit activity class

Hi I integrated my android app with CometChat, when i load conversations it loads correctly but when i try to view chats i get the following error. please assist.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pasp.salontrack, PID: 30030
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.pasp.salontrack/screen.messagelist.CometChatMessageScreen}; have you declared this activity in your AndroidManifest.xml?
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2065)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1727)
    at android.app.Activity.startActivityForResult(Activity.java:5315)
    at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
    at android.app.Activity.startActivityForResult(Activity.java:5273)
    at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662)
    at android.app.Activity.startActivity(Activity.java:5659)
    at android.app.Activity.startActivity(Activity.java:5612)
    at com.pasp.salontrack.activities.ConversationsActivity$1.OnItemClick(ConversationsActivity.java:33)
    at com.pasp.salontrack.activities.ConversationsActivity$1.OnItemClick(ConversationsActivity.java:24)
    at screen.CometChatConversationListScreen$2.OnItemClick(CometChatConversationListScreen.java:134)
    at screen.CometChatConversationListScreen$2.OnItemClick(CometChatConversationListScreen.java:130)
    at com.cometchat.pro.uikit.CometChatConversationList$1.onClick(CometChatConversationList.java:124)
    at listeners.RecyclerTouchListener.onInterceptTouchEvent(RecyclerTouchListener.java:34)
    at androidx.recyclerview.widget.RecyclerView.findInterceptingOnItemTouchListener(RecyclerView.java:3151)
    at androidx.recyclerview.widget.RecyclerView.onInterceptTouchEvent(RecyclerView.java:3170)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2640)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3047)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2756)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3047)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2756)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3047)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2756)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3047)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2756)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3047)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2756)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3047)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2756)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3047)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2756)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3047)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2756)
    at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:488)
    at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1885)
    at android.app.Activity.dispatchTouchEvent(Activity.java:4120)
    at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
    at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:446)
    at android.view.View.dispatchPointerEvent(View.java:14560)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5991)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5794)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5285)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5342)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5308)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5460)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5316)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5517)

E/AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5289)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5342)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5308)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5316)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5289)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8055)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8006)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7967)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:8183)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:220)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:335)
at android.os.Looper.loop(Looper.java:183)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Hi @thobaniz,

Please replace it with CometChatMessageListActivity.java as it is activity class which loads a fragment called CometChatMessageScreen.java

Hi @darshan.bhanushali it looks like CometChatMessageScreenActivity class does not exist, i get the following error if i try to replace with it

Full view of the implementation

Can you please replace it with CometChatMessageListActivity.java. You can check this in uikit/screen/messagelist.

I used CometChatMessageListActivity.java and i am now getting a different error, seems like i need to set an avatar somewhere but i don’t know how do i do that. I don’t want to interfere with your classes unless i am being advised to do so.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.pasp.salontrack, PID: 31474
    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
        at com.cometchat.pro.uikit.Avatar.setInitials(Avatar.java:375)
        at screen.messagelist.CometChatMessageScreen.setAvatar(CometChatMessageScreen.java:957)
        at screen.messagelist.CometChatMessageScreen.initViewComponent(CometChatMessageScreen.java:326)
        at screen.messagelist.CometChatMessageScreen.onCreateView(CometChatMessageScreen.java:278)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2698)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:310)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1185)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1354)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1432)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1495)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447)
        at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2167)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1990)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1945)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1847)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2621)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2569)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1435)
        at android.app.Activity.performStart(Activity.java:8013)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3367)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7478)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)

I started debugging the library and i keep on getting errors that are no related to my app, i don’t know what went wrong because i followed the online step by step in this link https://www.cometchat.com/tutorials/how-to-build-an-android-chat-app-in-java.

Please provide me with a full setup video so i can follow it, i want to move on with the development.

Thanks

Hi @thobaniz,

I will suggest you please replace your code with the below code.

public class ConversationsActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_conversations);
        CometChatConversationListScreen.setItemClickListener(new OnItemClickListener<Conversation>() {
            @Override
            public void OnItemClick(Conversation var, int position) {
                User user = (User)var.getConversationWith();
                Intent intent = new Intent(ConversationsActivity.this,CometChatMessageListActivity.class);
                intent.putExtra(StringContract.IntentStrings.UID, user.getUid());
                intent.putExtra(StringContract.IntentStrings.NAME, user.getName());
                intent.putExtra(StringContract.IntentStrings.AVATAR, user.getAvatar());
                intent.putExtra(StringContract.IntentStrings.TYPE, CometChatConstants.RECEIVER_TYPE_USER);
                startActivity(intent);
            }
            @Override
            public void OnItemLongClick(Conversation var, int position) {
                super.OnItemLongClick(var, position);
           }
        });
    }
    public void newChatTapped(View view) {
        startActivity(new Intent(ConversationsActivity.this, ContactsActivity.class));
    }
}

Hi, Thank you for the suggested code, however this code take me back to the very first error I posted android.content.ActivityNotFoundException: Unable to find explicit activity class {com.pasp.salontrack/screen.messagelist.CometChatMessageScreen}; have you declared this activity in your AndroidManifest.xml?. I tried to change the class name from CometChatMessageScreen.class to CometChatMessageListActivity.class and doing that gave me the Avatar error I posted previously java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference

and these are the only two classes I have under screen/messagelist

Any response on this?

Hi @thobaniz,

CometChatMessageScreen is a fragment class in the UIKit library. You cannot use this class through intent. We request you to please use CometChatMessageListActivity.

CometChatMessageListActivity is a activity class which holds a CometChatMessageScreen fragment

Please check the code mentioned in the previous post.

We also suggest you refer our sample app for your reference.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.