GithubHelp home page GithubHelp logo

Comments (8)

hs-kdhillon avatar hs-kdhillon commented on July 23, 2024

Another similar issue logged here #455. It was closed to unresponsive OP.

from dd-sdk-android.

xgouchet avatar xgouchet commented on July 23, 2024

Hi @hs-kdhillon
Thanks for reporting this issue. The official android source code explicitely mentions the menu is supposed to be NonNull and the WindowCallbackWrapper class in our SDK uses Kotlin to delegate it to the wrapped callback. All that considered, we are missing more information to reproduce and fix this issue.

Can you share with us the xml file used to create the menu, and any other useful information to understand how a menu can be passed as null ?

from dd-sdk-android.

hs-kdhillon avatar hs-kdhillon commented on July 23, 2024

chat_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    >

    <item
        android:id="@+id/action_phone"
        android:orderInCategory="100"
        android:title="Phone"
        app:showAsAction="always"
        android:icon="@drawable/ic_call_button"/>

    <item
        android:id="@+id/action_hired"
        android:orderInCategory="100"
        android:title="Hired"
        app:showAsAction="never" />

    <item
        android:id="@+id/action_nothired"
        android:orderInCategory="100"
        android:title="Not Hired"
        app:showAsAction="never" />

    <item
        android:id="@+id/action_accept"
        android:orderInCategory="100"
        android:title="Accept"
        app:showAsAction="never" />

    <item
        android:id="@+id/action_decline"
        android:orderInCategory="100"
        android:title="Decline"
        app:showAsAction="never" />

    <item
        android:id="@+id/action_archive"
        android:orderInCategory="100"
        android:title="Archive"
        app:showAsAction="never" />

    <item android:id="@+id/action_unarchive"
        android:orderInCategory="100"
        android:title="Unarchive"
        app:showAsAction="never" />

    <item
        android:id="@+id/action_share"
        android:orderInCategory="100"
        android:title="Share"
        app:showAsAction="never" />

</menu>

ChatActivity

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
    menuInflater.inflate(R.menu.chat_menu, menu)
    return true
}

override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
        menu?.findItem(R.id.action_phone)?.isVisible = viewModel.isPhoneButtonVisible().value?: false
        menu?.findItem(R.id.action_accept)?.isVisible = viewModel.isAcceptDeclineButtonsVisible().value?: false
        menu?.findItem(R.id.action_decline)?.isVisible = viewModel.isAcceptDeclineButtonsVisible().value?: false
        menu?.findItem(R.id.action_share)?.isVisible = viewModel.isShareButtonVisible().value?: false
        menu?.findItem(R.id.action_archive)?.isVisible = viewModel.isArchiveButtonVisible().value?: false
        menu?.findItem(R.id.action_unarchive)?.isVisible = viewModel.isUnarchiveButtonVisible().value?: false
        menu?.findItem(R.id.action_hired)?.isVisible = viewModel.isHiredButtonVisible().value?: false
        menu?.findItem(R.id.action_nothired)?.isVisible = viewModel.isNotHiredButtonVisible().value?: false
        return super.onPrepareOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
        when {
            item!!.itemId == R.id.action_share -> viewModel.onShareClicked()
            item.itemId == android.R.id.home -> onBackPressed()
            item.itemId == R.id.action_accept -> viewModel.onAcceptClicked()
            item.itemId == R.id.action_decline -> viewModel.onDeclineClicked()
            item.itemId == R.id.action_phone -> viewModel.onPhoneClicked()
            item.itemId == R.id.action_unarchive -> viewModel.onUnarchiveClicked()
            item.itemId == R.id.action_hired -> viewModel.onHiredClicked()
            item.itemId == R.id.action_nothired -> viewModel.onNotHiredClicked()
        }

        return super.onOptionsItemSelected(item)
}

Is the absence of nullability check here causing the error override fun onOptionsItemSelected(item: MenuItem?): Boolean? This is an old project, and not my code.

from dd-sdk-android.

hs-kdhillon avatar hs-kdhillon commented on July 23, 2024

Seems like onOptionItemsSelected signature has changed to onOptionsItemSelected(item: MenuItem): Boolean. I'll test the app with this new change, and update the issue with the findings.

from dd-sdk-android.

hs-kdhillon avatar hs-kdhillon commented on July 23, 2024

Changing the signatures did nothing. App still crashes when menu is clicked on. Removing the dataDog dependency, however doesn't crash the app.

from dd-sdk-android.

xgouchet avatar xgouchet commented on July 23, 2024

Hi @hs-kdhillon, even when using your menu I couldn't reproduce this issue at first. I dug into the androidx.appcompat source code and found a bug in the version 1.1.0 which was solved in 1.2.0.

In your dependencies, can you make sure you're using "androidx.appcompat:appcompat:1.2.0" or higher. This should make this crash disappear.

from dd-sdk-android.

hs-kdhillon avatar hs-kdhillon commented on July 23, 2024

Hi @xgouchet , can confirm the bug was related to androidx.appcompat:appcompat as the project was using version 1.0.0 and upgrading to version 1.2.0 fixed it 👍. Can you attach the link where this issue is mentioned @xgouchet ? would be helpful for post-analysis. And thank you for your swift help as always 💯 .

Closing the issue now.

from dd-sdk-android.

xgouchet avatar xgouchet commented on July 23, 2024

Of course, here's the official issue in the appcompat project: https://issuetracker.google.com/issues/142843126

from dd-sdk-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.