编辑:我的PROGUARD版本是4.7
今天我尝试在我的Android应用程序中包含jsoup (version 1.7.1)
,但它给我带来了很多麻烦。每当我的应用程序面临强制关闭问题时,当我导出已签名的apk
且proguard
已打开时,我就会停用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
答案 0 :(得分:43)
@Erdem在上面评论中发布的解决方案似乎是最好的解决方案。我将它作为可见性的答案重新发布。
将以下行添加到您的proguard文件
-keeppackagenames org.jsoup.nodes
这似乎足够了
答案 1 :(得分:29)
您可以转到jsoup with proguard查找答案,即将以下内容添加到proguard-project.txt
:
-keep public class org.jsoup.** {
public *;
}
答案 2 :(得分:0)
只需将这些行添加到proguard-rules.txt
#Jsoup
-keep public class org.jsoup.** {
public *;
}
-keeppackagenames org.jsoup.nodes