2

I need to get some data from external server in an android app. for that i use

com.loopj.android:android-async-http:1.4.9

But my app crashed while initiating client in MainActivity

private MyClient client;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

   client = new MyCLient();
}

Then, if I run the app, it crashes. except new MyCLient() app is ok.

MyClient.java

package com.example.hellow;

import com.loopj.android.http.*;

 public class MyClient {

private static final String BASE_URL = "https://httpbin.org/";

private static AsyncHttpClient client = new AsyncHttpClient();

public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
      client.get(getAbsoluteUrl(url), params, responseHandler);
  }

  public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
      client.post(getAbsoluteUrl(url), params, responseHandler);
  }

  private static String getAbsoluteUrl(String relativeUrl) {
      return BASE_URL + relativeUrl;
  }

}
Dada
  • 6,313
  • 7
  • 24
  • 43
Forhad
  • 21
  • 5
  • Error file link: [link](http://pastebin.com/HC7vayG0) – Forhad Dec 20 '16 at 07:21
  • i tried with okhttp3. result is same. after calling OkHttpClient client = new OkHttpClient(); – Forhad Dec 20 '16 at 07:25
  • Please post your log. – Avinash Saran Dec 20 '16 at 09:31
  • [Log file link : pastebin](http://pastebin.com/HC7vayG0) – Forhad Dec 20 '16 at 11:22
  • Please Check whether the library is at perfect address- Caused by: java.lang.ClassNotFoundException: Didn't find class "cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory" on path: DexPathList[[zip file "/data/app/com.example.hellow-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] – Avinash Saran Dec 20 '16 at 18:57

0 Answers0