Rom*_*naV 18 android android-manifest
我正在尝试在其AndroidManifest.xml中使用具有此功能的库:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.imagepicker.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
Run Code Online (Sandbox Code Playgroud)
我的应用程序的AndroidManifest.xml中有相同的标记:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="@string/FileProviderAuthority"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
</provider>
Run Code Online (Sandbox Code Playgroud)
所以它显然给出了Manifest合并错误:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
Run Code Online (Sandbox Code Playgroud)
这建议在AndroidManifest.xml中"添加"工具:replace ="android:authorities"'来覆盖".
所以我tools:replace="android:authorities"在我的应用程序的AndroidManifest.xml中添加如下:
<application
tools:replace="android:authorities"
android:name=".appcontroller.AppController"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
Run Code Online (Sandbox Code Playgroud)
然后我收到这个错误:
Error:
tools:replace specified at line:25 for attribute android:authorities, but no new value specified
Run Code Online (Sandbox Code Playgroud)
同样的事情发生在tools:replace="android.support.v4.content.FileProvider".
我错过了什么?
小智 29
要解决此问题,有两种选择:要么更改清单以使用不同的类,android.support.v4.content.FileProvider要么创建PR /问题,要求lib的所有者更改他/她(这将是最好的情况).
如果您想快速修复,只需创建一个扩展的类,FileProvider例如:
import android.support.v4.content.FileProvider;
public class MyFileProvider extends FileProvider {
}
Run Code Online (Sandbox Code Playgroud)
并在您的清单文件中,您将其更改为:
<provider android:name=".MyFileProvider" ... >
Run Code Online (Sandbox Code Playgroud)
JP *_*ura 16
添加到您的AndroidManifest.xml文件,application标签内:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"
tools:replace="android:resource" />
</provider>
Run Code Online (Sandbox Code Playgroud)
对于使用 sdk 28 及更高版本的用户,如果您要迁移到 androidx,解决方案是:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8934 次 |
| 最近记录: |