“setsupportactionbar parameter Error” error encounters due to the importation of an incomplete package. You have imported the package

import android.widget.Toolbar;
Solution: setsupportactionbar parameter Error
You have to replace the action bar with api27’s toolbar.
And change to :
import androidx.appcompat.widget.Toolbar;