微信分享朋友圈报错 分享异常 Android 11及以上系统的手机需要使用FileProvider方式分享
项目集成了友盟的分享,在Android 11系统手机上,微信分享朋友圈失败:
集成时以按文档配置了FileProvider,具体步骤:
Android Manifest XML中添加
<activity
android:name=".wxapi.WXEntryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_paths" />
</provider>
需要建一个xml添加file_provider_paths.xml文件
<external-files-path name="umeng_cache" path="umeng_cache/"/>
初始化友盟时调用PlatformConfig.setWXFileProvider(”{applicationId}.provider“)
如果还未能解决问题,需要注意:
需要使用完整版微信,我报错时使用的jar包为:umeng-share-wechat-simplify-7.1.3,替换为完整版jar包:umeng-share-wechat-full-7.1.4。之后重新编译运行解决。
完整版下载方式