Implementing BaseOnSliderTouchListener's onStartTrackingTouch and onStopTrackingTouch (documentation) give the lint the following error message :
Error: BaseOnSliderTouchListener.onStartTrackingTouch can only be called from within the same library group (referenced groupId=com.google.android.material from groupId=your-group-id) [RestrictedApi]
Temporary solution:
Add @SuppressLint("RestrictedApi") annotation.
Example:
slider.addOnSliderTouchListener(object : Slider.OnSliderTouchListener {
@SuppressLint("RestrictedApi")
override fun onStartTrackingTouch(slider: Slider) {
[...]
}
@SuppressLint("RestrictedApi")
override fun onStopTrackingTouch(slider: Slider) {
[...]
}
})
I had the same issue. The workaround with @SuppressLint("RestrictedApi") works.
The root cause is that the BaseOnSliderTouchListener class has a library restricted scope and the methods exposed there are not overridden in OnSliderTouchListener.
The issue is tracked in the material-components library here: https://github.com/material-components/material-components-android/issues/2493
It has been fixed in the 1.6.0-alpha02 release of material-components.