How to add Jsoup to my Android Studio project?

user1788736 picture user1788736 · Jul 7, 2017 · Viewed 18.3k times · Source

I am trying to use jsoup in my android studio project but i keep getting this error: Error:(10, 16) Gradle: error: package org.jsoup does not exist.

Could you guys tell me the steps on how to add jsoup library to my project? Thanks in advance.

Edit: For learning purpuse i am running the java code alone without main activity!

code:

package com.jsoupTest.jsoupTest;


import java.io.IOException;




import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.UnsupportedMimeTypeException;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class JsoupGetRequest {


    public static void main(String[] args) throws IOException {



        String dc=Jsoup.connect("http://somelink.com").timeout(6000).get();
        System.out.println(dc);
    }

}

Answer

ZeroOne picture ZeroOne · Jul 7, 2017

Gradle (build.gradle) in your app folder. put under dependencies section. clean and rebuild project

// jsoup HTML parser library @ https://jsoup.org/
implementation 'org.jsoup:jsoup:1.10.3'