Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing with jsoup throws error (NetworkOnMainThreadException)
    primarykey
    data
    text
    <p>I downloaded the jsoup library <strong>jsoup-1.7.1.jar core</strong> and imported it to my project using the <strong>Project -> Properties->Java Build Path -> Add external Jars</strong> and I pasted the library file to my libs folder. However there seems to be some problem about importing the Jsoup library to my project. When I run my app, upon launching I get this error. </p> <pre><code>12-26 22:59:24.133: E/AndroidRuntime(6710): FATAL EXCEPTION: main 12-26 22:59:24.133: E/AndroidRuntime(6710): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jsouptest/com.example.jsouptest.MainActivity}: android.os.NetworkOnMainThreadException </code></pre> <p>After searching and asking I found out that eclipse sees the jsoup.jar, but unable to package it to APK file for the app to run. I tried to organize Imports by pressing <strong>Shift+Alt+O</strong> and I would get the same error. At this point, I am unsure about what is wrong and have no idea how to fix it. I have only hope someone will lead me toward the solution. Appreciate your time! </p> <p>This is my code: </p> <pre><code>package com.example.jsouptest; import java.io.IOException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import android.app.Activity; import android.os.Bundle; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Document doc; try { doc = Jsoup.connect("http://google.com/").get(); String title = doc.title(); System.out.print(title); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload