本文介绍了ContentProvider模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用库,问题始于:

I'm ussing this library, the problem starts with:

失败[INSTALL_FAILED_CONFLICTING_PROVIDER]

Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]

因为我之前没有读过这篇文章,所以我使用该库修复了多线程SharedPreference的问题,因此该项目必须放入一个模块中才能在多个项目中使用.

because i didn't read this before, i used this library to fix problems with multi thread SharedPreference, this project had to become in a module to use in multiple projects.

在使用此模块安装每个应用程序时,抛出失败[INSTALL_FAILED_CONFLICTING_PROVIDER] 异常.

At the moment of installing every App with this Module, throws the Failure [INSTALL_FAILED_CONFLICTING_PROVIDER] exception.

因为权限已在第一个安装的应用中使用.

Because authority is already used in the first installed app.

  • 如何跳过已安装的模块的安装? (安装了该应用程序的其余部分,因此错误会消失)

  • How can i skip installation of Module that is already installed? (Installing the rest of the app, so error will disapear)

否则,我该如何构建项目?才能安装使用带有ContentProvider库的模块构建的多个应用.

else, How can i structure the projects? to be able to install multiple apps built with the Module that have the ContentProvider Library.

推荐答案

已修复

对于需要类似内容的人,请遵循以下步骤:

Fixed

For those that need something similar these are the steps to follow:

第1步.我在"主项目"中配置了纸盘库",其余的应用程序都需要"(托管数据库首选项的应用)

Step 1. I configured Tray Library in a Main Project "required for the rest of apps"(the app that hosts database preferences)

步骤2.我从存储库中提取了与Tray ContentProvider连接所需的类,

Step 2. I extracted from repository the required classes to connect with the Tray ContentProvider, which are:

位于通用模块的新包装中.

in a new package for the common Module.

第3步.我通过常量变量对权限名称进行了硬编码:

Step 3. I hardcoded authority name via constant variable:

这必须与主项目配置相符:

// bild.gradle of Main Project
resValue "string", "tray__authority", "<your.app.package>.tray"


// TrayContract.java of Module
@NonNull
private static String getAuthority(@NonNull final Context context) {
    return TextUtils.isEmpty(sTestAuthority) ?
            AppConstant.TRAY_AUTHORITY: // <-- this one = <your.app.package>.tray
            sTestAuthority;
}

最后,我可以正常使用该类:

Finally I can use the class normally:

// etc
import <your.app.package>.tray.TrayPreferences;
// etc
public class AppPreferencesManager extends TrayPreferences {
// etc
}

它起作用了:)

这篇关于ContentProvider模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 18:11