gradle Flutter / Android XmlPullParserException,但仅在发布模式、调试和配置文件中有效

mw3dktmi  于 2022-11-14  发布在  Flutter
关注(0)|答案(1)|浏览(141)

在我的Flutter应用中,我调用了一个Java框架(Smack),如果我将其编译为调试或配置文件,它确实工作得很好,但不是在发布模式下。我猜这一定与构建过程中的一些复杂性有关。
调用堆栈中的相关行如下:

Caused by: org.xmlpull.v1.XmlPullParserException: unsupported feature: XMLPULL FAQ (position:START_DOCUMENT null@1:1)
at org.kxml2.io.KXmlParser.setFeature(KXmlParser.java:2102)

有人知道吗?任何帮助都非常感谢!
下面是完整的堆栈跟踪:

java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.util.ServiceConfigurationError: h8.e: Provider i8.b could not be instantiated
at java.util.ServiceLoader.fail(ServiceLoader.java:233)
at java.util.ServiceLoader.-wrap1(Unknown Source:0)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:392)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:416)
at java.util.ServiceLoader$1.next(ServiceLoader.java:494)
at h8.a.a(Unknown Source:17)
at h8.a.b(Unknown Source:0)
at d8.a0.d(Unknown Source:7)
at a7.z.d(Unknown Source:0)
at a7.z.c(Unknown Source:6)
at a7.z.(Unknown Source:97)
at a7.u.b(Unknown Source:0)
at a7.u.a(Unknown Source:7)
at a7.k.(Unknown Source:26)
at p4.b.a(Unknown Source:5)
at p4.b.doInBackground(Unknown Source:2)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.newInstance(Native Method)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:388)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:416)
at java.util.ServiceLoader$1.next(ServiceLoader.java:494)
at h8.a.a(Unknown Source:17)
at h8.a.b(Unknown Source:0)
at d8.a0.d(Unknown Source:7)
at a7.z.d(Unknown Source:0)
at a7.z.c(Unknown Source:6)
at a7.z.(Unknown Source:97)
at a7.u.b(Unknown Source:0)
at a7.u.a(Unknown Source:7)
at a7.k.(Unknown Source:26)
at p4.b.a(Unknown Source:5)
at p4.b.doInBackground(Unknown Source:2)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: org.xmlpull.v1.XmlPullParserException: unsupported feature: XMLPULL FAQ (position:START_DOCUMENT null@1:1)
at org.kxml2.io.KXmlParser.setFeature(KXmlParser.java:2102)
at i8.b.(Unknown Source:25)
at java.lang.Class.newInstance(Native Method)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:388)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:416)
at java.util.ServiceLoader$1.next(ServiceLoader.java:494)
at h8.a.a(Unknown Source:17)
at h8.a.b(Unknown Source:0)
at d8.a0.d(Unknown Source:7)
at a7.z.d(Unknown Source:0)
at a7.z.c(Unknown Source:6)
at a7.z.(Unknown Source:97)
at a7.u.b(Unknown Source:0)
at a7.u.a(Unknown Source:7)
at a7.k.(Unknown Source:26)
at p4.b.a(Unknown Source:5)
at p4.b.doInBackground(Unknown Source:2)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
jv2fixgn

jv2fixgn1#

我解决了这个问题。ProGuard优化步骤把事情搞砸了,并损坏了代码。当我把这些自定义添加到proGuard配置中时:

-keep class org.jivesoftware.** { *; }
-keep class org.xmlpull.** { *; }
-keep class org.bouncycastle.jcajce.provider.** { *; }

然后Smack在Flutter / Android中为我工作

相关问题