1

I'm trying to parse HTML into android using Jsoup. When I'm trying to connect to url, I get error

Document doc = null;  
        try {
            doc = Jsoup.connect("http://en.wikipedia.org/").get();
        } catch (IOException e) {
            e.printStackTrace();
        }

Errors:

12-08 13:27:11.254 28041-28041/? E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
12-08 13:27:11.284 28041-28041/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.example.krzych.taksometr, PID: 28041
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.krzych.taksometr/com.example.krzych.taksometr.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class selector

XML Main Activity

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.krzych.taksometr.MainActivity">

    <TextView
        android:id="@+id/tekst"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>
5
  • can you post your main activity xml code as well as your whole MainActivity java code? Commented Dec 8, 2017 at 13:13
  • 1
    This error doesn't say anything about Jsoup. It is related to your xml code. Commented Dec 8, 2017 at 13:21
  • i think your problem is in android.graphics.drawable.RippleDrawable tag in XML please post your xml file here Commented Dec 8, 2017 at 13:25
  • this is not a jsoup error Commented Dec 8, 2017 at 19:40
  • There is an xml file. I'm not using android.graphics.drawable.RippleDrawable Commented Dec 9, 2017 at 9:17

1 Answer 1

1

this works for me :

 button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new JsoupParser().execute();

        }

    });
}
public class JsoupParser extends AsyncTask<String,Integer,String> {
    String title;
    String s = editText.getText().toString();//get url from EditText 
    Document doc;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        textView.setText("");
    }

    @Override
    protected String doInBackground(String... params) {
        try {
            doc = Jsoup.connect(s).get();
            title = doc.title();

            }
        catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(String result) {

        textView.setText(title);
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.