Open kandrio opened 1 year ago
I just found out that the latest version of the androidx.appcompat:appcompat
dependency that contains the AppCompatActivity
that we're using depends on androidx.activity:activity:1.1.0
which is lower than 1.4.0
where the new API was introduced. So, it seems that if we want to get rid of this deprecation warning, we must use a different Activity than AppCompatActivity
.
Overview
This is part of #161.
In a number of Fragments in the superapp, we use
setHasOptionsMenu
in order to declare that a given Fragment would like to participate in populating the options menu by receiving a call toonCreateOptionsMenu
. However, thesetHasOptionsMenu
API is deprecated and its use produces a number of deprecation warnings when we build the superapp. Therefore, in an effort to clean the superapp from deprecation warnings, we want to replace this API with its modern counterpart.Recommended Actions
The Android Developer documentation proposes that we use the
addMenuProvider()
API instead. This API function a member function ofComponentActivity
. Here is the relevant code example that shows an example of how to use that API:The Problem
The
addMenuProvider()
API was introduced in version1.4.0
of AndroidX Activity. In order to declare that version, I guessed that I should add the following line to thebuild.gradle
of each module (e.g:debug
,musicdao
etc...):implementation 'androidx.activity:activity:1.4.0'
.But that doesn't correctly upgrade
ComponentActivity
so that it implements theaddMenuProvider()
function that we need. Let's take thedebug
module for example to show what's going on.DebugActivity
inherits from theBaseActivity
BaseActivity
inherits from the AndroidXAppCompatActivity
.AppCompatActivity
->FragmentActivity
->ComponentActivity
), we derive thatDebugActivity
inherits fromComponentActivity
, therefore we should be able to use the desiredaddMenuProvider()
member function ofComponentActivity
.However, when I trace back the code, I see that we're still using an outdated version of activity (version
1.2.0
instead of the desired1.4.0
) and I can't seem to update it through the build.gradle file.@InvictusRMC Any ideas?
CC @synctext