无法获取BuglyFileProvider
                
 # 出现情景
项目本来运行好好的,周末回来再运行报了个错误.
java.lang.RuntimeException: Unable to get provider : java.lang.ClassNotFoundException: Didn't find class "com.tencent.bugly.beta.utils.BuglyFileProvider" on path: DexPathList[[dex file
# 原因:
使用Bugly应用升级的时候参考文档使用late.release没有指定版本,也没有配置BuglyFileProvider.
implementation 'com.tencent.bugly:crashreport_upgrade:late.release'
 1

而应用升级SDK在1.5.23版本之后适配Android X,之前没配置BuglyFileProvider就会产生问题
# 解决方法:
# 1. 指定1.3.1-1.5.23之间版本
implementation 'com.tencent.bugly:crashreport_upgrade:1.5.0'
 1
Bugly应用升级SDK版本 (opens new window)
# 2. 配置BuglyFileProvider
import android.support.v4.content.FileProvider;
 
 public class BuglyFileProvider extends FileProvider {
 }
 1
2
3
4
2
3
4
<provider
    android:name=".utils.BuglyFileProvider"
    android:authorities="${applicationId}.fileProvider"
    android:exported="false"
    android:grantUriPermissions="true"
    tools:replace="name,authorities,exported,grantUriPermissions">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"
        tools:replace="name,resource"/>
</provider>
 1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- /storage/emulated/0/Download/${applicationId}/.beta/apk-->
    <external-path name="beta_external_path" path="Download/"/>
    <!--/storage/emulated/0/Android/data/${applicationId}/files/apk/-->
    <external-path name="beta_external_files_path" path="Android/data/"/>
</paths>
 1
2
3
4
5
6
7
2
3
4
5
6
7
上次更新: 2021/06/24, 11:50:15