title: Android java http Xml conversion to Json Caused by: java.lang.NoSuchMethodError: No direct method <init>(Ljava/io/Reader;)
body: <p>I have to convert an Xml file at a very heavy http into a Json file.</p>
  
  <p>I tried to use: <code>implementation 'org.json: json: 20180813'</code></p>
  
  <p>But it gives me the following error:</p>
  
  <pre><code>Caused by: java.lang.NoSuchMethodError: No direct method &lt;init&gt; (Ljava / me / Reader;) V in class Lorg / json / JSONTokener; or its super classes (declaration of 'org.json.JSONTokener' appears in /system/framework/core-libart.jar)
          at org.json.XMLTokener. &lt;init&gt; (XMLTokener.java:57)
          at org.json.XML.toJSONObject (XML.java:516)
          at org.json.XML.toJSONObject (XML.java:548)
          at org.json.XML.toJSONObject (XML.java:472)
  </code></pre>
  
  <p>If I go to the build.gradle file, on the lib in question it tells me:</p>
  
  <pre><code>json defines classes that conflict with classes now provided by Android. Solutions includes finding newer versions or alternative libraries that do not have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar.
  </code></pre>
  
  <p>So I tried to use: <a href="https://stackoverflow.com/a/47410498/8024296">Link</a></p>
  
  <p>But it does not work.</p>
  
  <p>Can you tell me where I'm wrong?
  Or a solution.</p>
  
  <p>Code http:</p>
  
  <pre><code>private class Html extends AsyncTask&lt;Void, Void, Void&gt; {
  
          private String url = "https://pastebin.com/raw/ExP2Mm2k";
          private JSONArray listCh = new JSONArray();
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
          }
  
          @Override
          protected Void doInBackground(Void... params) {
              try {
                  Log.v("Class:" + TAG, "doInBackground:" + url);
  
                  String jsonString = Jsoup.connect(url).execute().body();
                  //Log.v("Class:" + TAG, "" + jsonString);
  
                 /* try {
                      JSONObject xmlJSONObj = XML.toJSONObject(jsonString);
                      String jsonPrettyPrintString = xmlJSONObj.toString(4);
                      System.out.println(jsonPrettyPrintString);
                  } catch (JSONException je) {
                      System.out.println(je.toString());
                  }*/
  
                  try {
                      JSONObject json = new JSONObject(jsonString);
                      JSONArray list = json.getJSONObject("list").getJSONArray("item");
                      //Log.v("Class:" + TAG, String.valueOf(listCh));
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
  
  
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              populateListItem(listCh);
          }
  
      }
  </code></pre>