Didn't find class "androidx.core.content.FileProvider" on path...

這個 bug 跟 AndroidManifest 中的 一塊設置有關:

 <provider
     android:name="androidx.core.content.FileProvider"
     android:authorities="com.example.instance"
     android:exported="false"
     android:grantUriPermissions="true">
     <meta-data
         android:name="android.support.FILE_PROVIDER_PATHS"
         android:resource="@xml/file_path" />
 </provider>

原因查找:

在 app\build.gradle 中少了一個配置——

compileOptions {
	// 1.8 是我的 jdk 版本
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

將上面配置代碼放到 android{} 中即可~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章