gpt4 book ai didi

android - java.lang.RuntimeException : An error occured while executing doInBackground() with jsoup 错误

转载 作者:行者123 更新时间:2023-11-29 16:00:15 26 4
gpt4 key购买 nike

我是 Android 开发的初学者,我收到此错误,导致我的 Asynctask 无法使用 UI 工作:

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:841)

我不明白为什么。我正在使用安卓工作室。在构建发布之前,我的应用程序运行良好,但现在崩溃了。这是我的课:

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pageNumber = getArguments().getInt(ARGUMENT_PAGE_NUMBER);
}

public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_my, null);
lv = (ListView) view.findViewById(R.id.listView1);
adapter = new ArrayAdapter<String>(getActivity(), R.layout.list_item, R.id.product_name, titleList);
new NewThread().execute();
return view;
}
public class NewThread extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... arg) {
Document doc;
try {
doc = Jsoup.connect("http://ot76.ru/mob/list.php?vt=" + (pageNumber + 1) + "&nl=0").get();
title = doc.select("a");
for (Element titles : title) {
titleList.add(titles.html().replace("&nbsp;", "(") + ") ");
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
lv.setAdapter(adapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String str = lv.getItemAtPosition(position).toString();
Intent intent = new Intent(getActivity().getApplicationContext(), Rasp.class);
intent.putExtra("url", "http://ot76.ru/mob/getroutestr.php?vt=" + (pageNumber + 1) + "&nl=0&nmar=" + str.substring(0, str.indexOf(' ')).replace("к", "k").replace("а", "a").replace("б", "b").replace("с", "c").replace("д", "d"));
intent.putExtra("stops", lv.getItemAtPosition(position).toString().substring(str.indexOf(' '), str.length() - 1));
startActivity(intent);
}
});
}
}

最佳答案

问题解决了。我只需要添加

-保持公共(public)类 org.jsoup.** {
民众 *;

到我的 proguard-android.txt 文件。

关于android - java.lang.RuntimeException : An error occured while executing doInBackground() with jsoup 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25121178/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com