Val Val - 8 days ago 5
Android Question

Exception after adding ProGuard to project

I've added ProGuard to my project and got this error. I guess It can be Jsoup lib which I using to send POST and GET requests and parse responses.

There are no separate line that throwns this exception.

Can you help me to solve this problem with ProGuard?

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
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:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:864)
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.String,java.lang.String,org.jsoup.parser.ParseErrorList)(Unknown Source)
boolean process(org.jsoup.parser.Token)
boolean process(org.jsoup.parser.Token,org.jsoup.parser.HtmlTreeBuilderState)
void transition(org.jsoup.parser.HtmlTreeBuilderState)
org.jsoup.parser.HtmlTreeBuilderState state()
void framesetOk(boolean)
void maybeSetBaseUri(org.jsoup.nodes.Element)
org.jsoup.nodes.Element insert(org.jsoup.parser.Token$StartTag)
org.jsoup.nodes.Element insert(java.lang.String)
void insert(org.jsoup.parser.Token$Comment)
void insert(org.jsoup.parser.Token$Character)
boolean isElementInQueue(org.jsoup.helper.DescendableLinkedList,org.jsoup.nodes.Element)
void popStackToClose(java.lang.String[])
void insertOnStackAfter(org.jsoup.nodes.Element,org.jsoup.nodes.Element)
void replaceInQueue(java.util.LinkedList,org.jsoup.nodes.Element,org.jsoup.nodes.Element)
boolean inSpecificScope(java.lang.String,java.lang.String[],java.lang.String[])
boolean inSpecificScope(java.lang.String[],java.lang.String[],java.lang.String[])
boolean inScope(java.lang.String,java.lang.String[])
void insertInFosterParent(org.jsoup.nodes.Node)
at org.jsoup.parser.Parser.org.jsoup.nodes.Document parseInput(java.lang.String,java.lang.String)(Unknown Source)
boolean isTrackErrors()
at org.jsoup.helper.DataUtil.org.jsoup.nodes.Document parseByteData(java.nio.ByteBuffer,java.lang.String,java.lang.String,org.jsoup.parser.Parser)(Unknown Source)
java.nio.ByteBuffer readToByteBuffer(java.io.InputStream,int)
java.lang.String getCharsetFromContentType(java.lang.String)
at org.jsoup.helper.HttpConnection$Response.org.jsoup.nodes.Document parse()(Unknown Source)
at com.ThreeBoots.api.API.java.lang.Object userLogin(java.lang.String,java.lang.String)(Unknown Source)
java.lang.Object userLoginFacebook(java.lang.String)
boolean userLogout()
boolean saveArticle(com.ThreeBoots.database.Article)
java.lang.String loadPhoto(android.graphics.Bitmap)
java.lang.String loadPhoto(android.widget.ImageView)
java.lang.Object userSaveProfile(java.lang.String,java.lang.String,java.lang.String)
java.lang.String sendRequest(java.lang.String,java.lang.String[])
java.lang.String sendImageLoadRequest(java.lang.String,android.graphics.Bitmap)
void processingBrands(org.json.JSONObject)
java.lang.Object getListFromJSON(java.lang.Class,org.json.JSONArray)
void insert(java.lang.Class,java.lang.Object)
at com.ThreeBoots.api.API.java.lang.Object userRegister(java.lang.String,java.lang.String)(Unknown Source)
boolean sync()
java.lang.String sendRequest(java.lang.String)
void processingMaterials(org.json.JSONObject)
at com.ThreeBoots.api.API.java.lang.Object userRegister(java.lang.String,java.lang.String)(Unknown Source)
boolean sync()
java.lang.String sendRequest(java.lang.String)
void processingMaterials(org.json.JSONObject)
at com.ThreeBoots.asyncs.RequestAsync.java.lang.Object doInBackground(java.lang.String[])(Unknown Source)
void asyncSaveArticlePostExecute(java.lang.Boolean)
void asyncRegistrationPostExecute(java.lang.Object)
void startMainActivity()
void startLoginActivity(android.app.Activity)
at com.ThreeBoots.asyncs.RequestAsync.java.lang.Object doInBackground(java.lang.Object[])(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
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)
... 20 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)
... 21 more

Answer

Do not add the parsing classes in your proguard to get obfuscate. keep it as it is. Write the below line in your proguard file

 -keep class yourclassname.** { *; }