1、DroidPlugin以module的形式引入。
2、将DroidPlugin的PluginManager.java中的public static final String STUB_AUTHORITY_NAME,将final修饰去掉。
3、在自己项目初始化DroidPlugin的地方(一般在application中)之前设置PluginManager.STUB_AUTHORITY_NAME的值。例如:PluginManager.STUB_AUTHORITY_NAME = getPackageName() + “.droidplugin_stub”;
4、把DroidPlugin的AndroidManifest.xml文件中的9个占坑provider复制到你项目的AndroidManifest.xml文件中,例如:
<provider
android:name="com.morgoo.droidplugin.stub.ContentProviderStub$StubP00"
android:authorities="@string/plugin_provider_authorities_P00"
tools:replace="android:authorities"
android:exported="false"
android:label="@string/stub_name_povider" />
<provider
android:name="com.morgoo.droidplugin.stub.ContentProviderStub$StubP01"
android:authorities="@string/plugin_provider_authorities_P01"
tools:replace="android:authorities"
android:exported="false"
android:label="@string/stub_name_povider" />
// 省略其它
.....
authorities属性的值中的plugin_provider_authorities_P00(共9个)需要在自己项目的build.gradle文件中配置。像这样配置:
productFlavors {
// 开发版
develop {
applicationId "com.xxx.xxx.develop"
resValue("string", "plugin_provider_authorities_P00", applicationId+".droidplugin_stub_P00")
resValue("string", "plugin_provider_authorities_P01", applicationId+".droidplugin_stub_P01")
resValue("string", "plugin_provider_authorities_P02", applicationId+".droidplugin_stub_P02")
resValue("string", "plugin_provider_authorities_P03", applicationId+".droidplugin_stub_P03")
resValue("string", "plugin_provider_authorities_P04", applicationId+".droidplugin_stub_P04")
resValue("string", "plugin_provider_authorities_P05", applicationId+".droidplugin_stub_P05")
resValue("string", "plugin_provider_authorities_P06", applicationId+".droidplugin_stub_P06")
resValue("string", "plugin_provider_authorities_P07", applicationId+".droidplugin_stub_P07")
resValue("string", "plugin_provider_authorities_P08", applicationId+".droidplugin_stub_P08")
}
// 内部版
internal {
applicationId "com.xxx.xxx.internal"
resValue("string", "plugin_provider_authorities_P00", applicationId+".droidplugin_stub_P00")
resValue("string", "plugin_provider_authorities_P01", applicationId+".droidplugin_stub_P01")
resValue("string", "plugin_provider_authorities_P02", applicationId+".droidplugin_stub_P02")
resValue("string", "plugin_provider_authorities_P03", applicationId+".droidplugin_stub_P03")
resValue("string", "plugin_provider_authorities_P04", applicationId+".droidplugin_stub_P04")
resValue("string", "plugin_provider_authorities_P05", applicationId+".droidplugin_stub_P05")
resValue("string", "plugin_provider_authorities_P06", applicationId+".droidplugin_stub_P06")
resValue("string", "plugin_provider_authorities_P07", applicationId+".droidplugin_stub_P07")
resValue("string", "plugin_provider_authorities_P08", applicationId+".droidplugin_stub_P08")
}
// 省略其它
.....
}