Android調用相機時找不到android.support.v4.content.FileProvider unresolved package 'content'

在AndroidManifest.xml的application中添加provider時提示unresolved package ‘content’

<provider
	<!--
		下一行代碼報錯 
		unresolved package 'content'
	-->
	android:name="android.support.v4.content.FileProvider"
	android:authorities="com.wocus.wine.fileprovider"
	android:exported="false"
	android:grantUriPermissions="true">
	<meta-data
		android:name="android.support.FILE_PROVIDER_PATHS"
		android:resource="@xml/filepaths" />
</provider>

查詢文檔可知,最新的Android標準將android.support.v4.content.FileProvider替換爲了androidx.core.content.FileProvider
將其更改即可

<provider
	android:name="androidx.core.content.FileProvider"
	android:authorities="com.wocus.wine.fileprovider"
	android:exported="false"
	android:grantUriPermissions="true">
	<meta-data
		android:name="android.support.FILE_PROVIDER_PATHS"
		android:resource="@xml/filepaths" />
</provider>
發佈了213 篇原創文章 · 獲贊 861 · 訪問量 125萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章