[英]android - cannot resolve symbol FileProvider
我正在嘗試測試 FileProvider 教程。
它要求在清單中包含:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.mydomain.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
</provider>
在清單中,我收到錯誤消息:
Cannot resolve symbol FileProvider
我按照這些 說明將 v4 支持庫添加到 Android Studio。 我將以下內容添加到 build.gradle 文件,但 gradle 同步失敗:
compile "com.android.support:support-v4:18.0.+"
我必須怎么做才能解決這個問題?
轉到“文件”>“使緩存無效/重新啟動”和“無效並重新啟動”。
我相信您所針對的支持庫的版本 (18.0.+) 太低了。 根據參考文檔,FileProvider 僅在 22.1.0 版中添加,因此您至少需要:
compile "com.android.support:support-v4:22.1.0"
我知道這太晚了,以防萬一你遇到同樣的問題,請參考
https://stackoverflow.com/a/58784995/5193899
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.camera.app.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths">
</meta-data>
</provider>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.