由于我的要求是我的应用程序具有从服务器创建自定义贴纸和贴纸的功能,因此单个内容提供程序会导致问题,我尝试了很多添加多个内容提供程序,这会在编辑配置中导致问题 如下所示
这就是我尝试在清单中添加提供程序的方式
<provider android:name=".whats_app_based_code.provider.StickerContentProvider" android:authorities="${contentProviderAuthority}" android:enabled="true" android:exported="true" android:readPermission="com.whatsapp.sticker.READ"> </provider> <provider android:name=".whats_app_based_code.provider.StickerContentProviderServer" android:authorities="${contentProviderAuthority}" android:enabled="true" android:exported="true" android:readPermission="com.whatsapp.sticker.READ"> </provider>
应用级 Gradle
安卓 {
compileSdkVersion 30
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.numan.stickersapp"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
def contentProviderAuthority = applicationId + ".WhatsAppLicensedCode.StickerContentProvider"
def contentProviderAuthority2 =applicationId+".WhatsAppLicensedCode.StickerContentProviderServer"
// Creates a placeholder property to use in the manifest.
manifestPlaceholders = [contentProviderAuthority: "\"${contentProviderAuthority}\""]
manifestPlaceholders = [contentProviderAuthorityserver: "\"${contentProviderAuthority2}\""]
// Adds a new field for the authority to the BuildConfig class.
buildConfigField("String", "CONTENT_PROVIDER_AUTHORITY", "\"${contentProviderAuthority}\"")
buildConfigField("String","CONTENT_PROVIDER_AUTHORITY_SERVER","\"${contentProviderAuthority2}\"")
buildConfigField 'String', 'STICKERS_BASE_URL', "\"https://firebasestorage.googleapis.com/\""
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}