I have been searching for 3 or 4 days about a solution on this. I have tried: Null Pointer exception in using support library share action provider or why MenuItemCompat.getAct
You have wrong namespace usage in XML:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:actionProviderClass="android.support.v7.widget.ShareActionProvider"
should be app:actionProviderClass (the provider class is from apk resources, not native android classes).
See https://stackoverflow.com/a/32602896/907576
You could just create a ShareActionProvider and assign it.
mShareActionProvider = new ShareActionProvider();
mShareActionProvider.setShareIntent(createShareIntent())
MenuItemCompat.setActionProvider(item, mShareActionProvider);