我的Android应用程序始终在Google Play控制台或Firebase上崩溃 测试,但可以在本地设备或我的PC上的仿真器上正常运行。我用 Jsoup从网站获取内容
这是产生错误document = Jsoup.connect((String)"google.com").get();
的代码,我认为这是原因
private class Title extends AsyncTask<Void, Void, Void> {
String title;
Document document;
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
try {
// Connect to the web site
document = Jsoup.connect((String)"google.com").get();
// Get the html document title
title = document.title();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// Set title into TextView
if(title.equals("WILLI")&&document!=null) {
getWebsite(document);
}
}
}
这是给我错误的日志:
java.lang.RuntimeException: An error occured while executing doInBackground()
FATAL EXCEPTION: AsyncTask #1
Process: com.ccs.itgvertretungsplan, PID: 10903
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.Comparable.compareTo(java.lang.Object)' on a null object reference
at java.util.Arrays.binarySearch(Arrays.java:524)
at java.util.Arrays.binarySearch(Arrays.java:494)
at org.jsoup.nodes.Entities$EscapeMode.codepointForName(Entities.java:52)
at org.jsoup.nodes.Entities.isBaseNamedEntity(Entities.java:93)
at org.jsoup.parser.Tokeniser.consumeCharacterReference(Tokeniser.java:172)
at org.jsoup.parser.TokeniserState.readCharRef(TokeniserState.java:1684)
at org.jsoup.parser.TokeniserState.access$100(TokeniserState.java:8)
at org.jsoup.parser.TokeniserState$2.read(TokeniserState.java:36)
at org.jsoup.parser.Tokeniser.read(Tokeniser.java:50)
at org.jsoup.parser.TreeBuilder.runParser(TreeBuilder.java:49)
at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:43)
at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:56)
at org.jsoup.parser.Parser.parseInput(Parser.java:32)
at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:104)
at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:666)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:225)
at com.ccs.itgvertretungsplan.SchuelerMyListFragment$Title.doInBackground(SchuelerMyListFragment.java:396)
at com.ccs.itgvertretungsplan.SchuelerMyListFragment$Title.doInBackground(SchuelerMyListFragment.java:382)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 more