21

编辑:我的 PROGUARD 版本是 4.7

今天我尝试jsoup (version 1.7.1)在我的android应用程序中包含,但它给我带来了很多麻烦。当我每次我的应用程序面临强制关闭问题时,我导出签名apkproguard 打开proguard,然后我禁用并导出它apk并且它运行完美。请帮我。我该如何解决这个错误?堆栈跟踪如下:

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:107
6)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:56
9)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.ExceptionInInitializerError
at org.jsoup.nodes.Document$OutputSettings.<init>(Unknown Source)
at org.jsoup.nodes.Document.<init>(Unknown Source)
at org.jsoup.parser.TreeBuilder.void initialiseParse(java.lang.String,java.lang.
String,org.jsoup.parser.ParseErrorList)(Unknown Source)
at org.jsoup.parser.TreeBuilder.org.jsoup.nodes.Document parse(java.lang.String,
java.lang.String,org.jsoup.parser.ParseErrorList)(Unknown Source)
                            boolean process(org.jsoup.parser.Token)
at org.jsoup.parser.HtmlTreeBuilder.org.jsoup.nodes.Document parse(java.lang.Str
ing,java.lang.String,org.jsoup.parser.ParseErrorList)(Unknown Source)
                                boolean process(org.jsoup.parser.Token)
                                boolean process(org.jsoup.parser.Token,org.j
soup.parser.HtmlTreeBuilderState)
                                void transition(org.jsoup.parser.HtmlTreeBui
lderState)
                                org.jsoup.parser.HtmlTreeBuilderState state(
)
                                void framesetOk(boolean)
                                void maybeSetBaseUri(org.jsoup.nodes.Element
)
                                org.jsoup.nodes.Element insert(org.jsoup.par
ser.Token$StartTag)
                                org.jsoup.nodes.Element insert(java.lang.Str
ing)
                                void insert(org.jsoup.parser.Token$Comment)
                                void insert(org.jsoup.parser.Token$Character
)
                                boolean isElementInQueue(org.jsoup.helper.De
scendableLinkedList,org.jsoup.nodes.Element)
                                void popStackToClose(java.lang.String[])
                                void insertOnStackAfter(org.jsoup.nodes.Elem
ent,org.jsoup.nodes.Element)
                                void replaceInQueue(java.util.LinkedList,org
.jsoup.nodes.Element,org.jsoup.nodes.Element)
                                boolean inSpecificScope(java.lang.String,jav
a.lang.String[],java.lang.String[])
                                boolean inSpecificScope(java.lang.String[],j
ava.lang.String[],java.lang.String[])
                                boolean inScope(java.lang.String,java.lang.S
tring[])
                                void insertInFosterParent(org.jsoup.nodes.No
de)
at org.jsoup.parser.Parser.org.jsoup.nodes.Document parse(java.lang.String,java.
lang.String)(Unknown Source)
at org.jsoup.Jsoup.org.jsoup.nodes.Document parse(java.lang.String)(Unknown Sour
ce)
at com.my.package.name.BalCheck.void doLogin(java.lang.String,java.lang
.String)(Unknown Source)
                                     void checkBal()
                                     void echo(java.lang.String)
at com.my.package.name.BalCheck.void doCheckBalance(java.lang.String,ja
va.lang.String)(Unknown Source)
at com.my.package.name.SmsPage$CheckUltooBalance.java.lang.Void doInBac
kground(java.lang.Void[])(Unknown Source)
                                                      void onPostExecute(jav
a.lang.Void)
at com.my.package.name.SmsPage$CheckUltooBalance.java.lang.Object doInB
ackground(java.lang.Object[])(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 5 more
Caused by: java.lang.ExceptionInInitializerError
at org.jsoup.nodes.Entities$EscapeMode.<clinit>(Unknown Source)
... 18 more
Caused by: java.lang.NullPointerException
at java.util.Properties.load(Properties.java:246)
at org.jsoup.nodes.Entities.java.util.Map loadEntities(java.lang.String)(Unknown
 Source)
at org.jsoup.nodes.Entities.<clinit>(Unknown Source)
... 19 more
4

3 回答 3

44

@Erdem 在上面的评论中发布的解决方案似乎是最好的解决方案。我将其重新发布为可见性的答案。

将下面的行添加到您的 proguard 文件中

-keeppackagenames org.jsoup.nodes

这似乎足够了

于 2015-08-23T18:26:15.093 回答
29

您可以使用 proguard 去jsoup寻找答案,即添加以下内容proguard-project.txt

-keep public class org.jsoup.** {
public *;
}
于 2013-01-29T09:31:08.480 回答
1

只需在 proguard-rules.txt 中添加这些行

#Jsoup
-keep public class org.jsoup.** {
public *;
}
-keeppackagenames org.jsoup.nodes
于 2018-12-24T14:09:00.950 回答