我正在尝试在Android项目中使用Jsoup,但是出现了错误。我正在使用Android Studio。我已将jsoup jar 1.8.2添加到libs文件夹中,并在build.gradle文件中添加了compile files('libs/jsoup-1.8.2.jar')这一行。奇怪的是,我在Eclipse中没有遇到任何类似的问题。有什么建议吗?谢谢!
protected Void doInBackground(Void... params) {
try {
// Connect to website
Document document = (Document) Jsoup.connect("http://www.example.com/").get();
// Get the html document title
websiteTitle = document.title();
Elements description = document.select("meta[name=description]");
// Locate the content attribute
websiteDescription = description.attr("content");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
PS:对于select方法,也会出现"Cannot resolve method 'select(java.lang.String)'"的错误。