plus_plugins
plus_plugins copied to clipboard
[Bug]: ShareFileProvider ... defineEntityReplacementText() not supported
Platform
Android 12
Plugin
share_plus
Version
7.0.0
Flutter SDK
3.13.9
Steps to reproduce
As soon as I add share_plus > 7.0.0 as a dependency my app crashes on the start in release mode and I get the error message below in logcat. I checked the install instructions for tags or content to add to AndroidManifest.xml, but could not find anything.
As soon as I remove the share_plus dependency again, everything works fine.
Code Sample
**No code needed**
Adding the dependency without any additional code is enough to crash it
I have the following proguard rules. Is it maybe somehow related to that?
(I did not change anything apart from upgrading share_plus and adding this proguard file)
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn com.huawei.android.os.BuildEx$VERSION
-dontwarn com.huawei.android.telephony.ServiceStateEx
-dontwarn com.huawei.hianalytics.process.HiAnalyticsConfig$Builder
-dontwarn com.huawei.hianalytics.process.HiAnalyticsConfig
-dontwarn com.huawei.hianalytics.process.HiAnalyticsInstance$Builder
-dontwarn com.huawei.hianalytics.process.HiAnalyticsInstance
-dontwarn com.huawei.hianalytics.process.HiAnalyticsManager
-dontwarn com.huawei.hianalytics.util.HiAnalyticTools
-dontwarn com.huawei.libcore.io.ExternalStorageFile
-dontwarn com.huawei.libcore.io.ExternalStorageFileInputStream
-dontwarn com.huawei.libcore.io.ExternalStorageFileOutputStream
-dontwarn com.huawei.libcore.io.ExternalStorageRandomAccessFile
-dontwarn org.bouncycastle.crypto.BlockCipher
-dontwarn org.bouncycastle.crypto.engines.AESEngine
-dontwarn org.bouncycastle.crypto.prng.SP800SecureRandom
-dontwarn org.bouncycastle.crypto.prng.SP800SecureRandomBuilder
-dontwarn com.huawei.hms.ads.identifier.AdvertisingIdClient$Info
-dontwarn com.huawei.hms.ads.identifier.AdvertisingIdClient
### Logs
```shell
FATAL EXCEPTION: main
Process: com.myapp.app, PID: 4824
java.lang.RuntimeException: Unable to get provider dev.fluttercommunity.plus.share.ShareFileProvider: org.xmlpull.v1.XmlPullParserException: defineEntityReplacementText() not supported
at android.app.ActivityThread.installProvider(ActivityThread.java:7464)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6976)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6747)
at android.app.ActivityThread.access$1500(ActivityThread.java:256)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7870)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: org.xmlpull.v1.XmlPullParserException: defineEntityReplacementText() not supported
at android.content.res.XmlBlock$Parser.defineEntityReplacementText(XmlBlock.java:139)
at androidx.core.content.b.h(Unknown Source:19)
at androidx.core.content.b.e(Unknown Source:11)
at androidx.core.content.b.attachInfo(Unknown Source:31)
at android.app.ActivityThread.installProvider(ActivityThread.java:7459)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6976)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6747)
at android.app.ActivityThread.access$1500(ActivityThread.java:256)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7870)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Flutter Doctor
➜ ~ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.9, on Pop!_OS 22.04 LTS 6.5.6-76060506-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.85.0)
[✓] Connected device (3 available)
[✓] Network resources
Checklist before submitting a bug
- [X] I searched issues in this repository and couldn't find such bug/problem
- [X] I Google'd a solution and I couldn't find it
- [X] I searched on StackOverflow for a solution and I couldn't find it
- [X] I read the README.md file of the plugin
- [X] I'm using the latest version of the plugin
- [X] All dependencies are up to date with
flutter pub upgrade - [X] I did a
flutter clean - [X] I tried running the example project
Hey @SimonErich , do you have minification turned on? Also, did you migrate your Android gradle config to 8.x?
Hello @AngeloAvv ,
yes, we had to upgrade to gradle 8.x because of an SDK needed in our app.
minifyEnabled is not set anywhere in my project, so I guess it is disabled by default.
@SimonErich I believe there's a combination of libraries that make the app crash during the startup. I have the very same gradle and share_plus configuration on multiple projects, but one of them is crashing with the error message you reported.
I was able to solve the crash by adding the following row into gradle.properties, looks like the behavior of R8 changed since gradle 8.x:
android.enableR8.fullMode=false
I got a similar error using share_plus 7.2.2 :
java.lang.RuntimeException: Unable to get provider dev.fluttercommunity.plus.share.ShareFileProvider: org.xmlpull.v1.XmlPullParserException: Binary XML file line #-1: expected start or end tag (position:Binary XML file line #-1)
at android.app.ActivityThread.installProvider(ActivityThread.java:7841)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7347)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7042)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8248)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #-1: expected start or end tag (position:Binary XML file line #-1)
at android.content.res.XmlBlock$Parser.nextTag(XmlBlock.java:378)
at f0.b.h(Unknown Source:19)
at f0.b.e(Unknown Source:11)
at f0.b.attachInfo(Unknown Source:31)
at android.app.ActivityThread.installProvider(ActivityThread.java:7836)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7347)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7042)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8248)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
I tried to add a res/raw/keep.xml file without success:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@xml/flutter_share_file_paths*" />
only android.enableR8.fullMode=false in gradle.properties fixes this crash.
Android Gradle Plugin 8.3 fixes this problem but leads to new one:
java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'i7.a' in call to 'int i7.a.next()'
Any update?
java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'i7.a' in call to 'int i7.a.next()'
This an issue with R8 configuration. By default since Gradle version 8 the R8 works in full mode which is a bit too aggressive and leads to such issues. To resolve it you need to either modify your proguard-rules.pro file or try to turn off the full mode of R8.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days