title: java.lang.NoSuchMethodError E/AndroidRuntime: FATAL EXCEPTION: Thread-4 Process: com.hikvision.open.app, PID: 20137
body: <p>I want to make an app to get the video from a web camera, but there is an exception. The tool which I used is Android Studio.</p>
  
  <p>The link that download project:
  <a href="https://pan.baidu.com/s/1C0NGT73Ct0wfzQYoYUW5JQ" rel="nofollow noreferrer">https://pan.baidu.com/s/1C0NGT73Ct0wfzQYoYUW5JQ</a></p>
  
  <blockquote>
    <p>EXCEPTION: E/AndroidRuntime: FATAL EXCEPTION: Thread-4
        Process: com.hikvision.open.app, PID: 20137
        java.lang.NoSuchMethodError: No direct method (Ljavax/net/ssl/SSLContext;)V in class
    Lorg/apache/http/conn/ssl/SSLSocketFactory; or its super classes
    (declaration of 'org.apache.http.conn.ssl.SSLSocketFactory' appears in
    /system/framework/framework.jar:classes3.dex)
            at com.hikvision.artemis.sdk.util.HttpUtil.sslClient(HttpUtil.java:499)
            at com.hikvision.artemis.sdk.util.HttpUtil.wrapClient(HttpUtil.java:478)
            at com.hikvision.artemis.sdk.util.HttpUtil.httpPost(HttpUtil.java:178)
            at com.hikvision.artemis.sdk.Client.execute(Client.java:53)
            at com.hikvision.artemis.sdk.ArtemisHttpUtil.doPostStringArtemis(ArtemisHttpUtil.java:182)</p>
  </blockquote>
  
  <pre><code>public void onClick(View view) {
      if (view.getId() == R.id.preview_button) {
          startActivity(new Intent(this, PreviewActivity.class));
      } else if (view.getId() == R.id.find_button) {
          String stringhost = host.getText().toString().trim();
          String stringkey = key.getText().toString().trim();
          String stringsecret = secret.getText().toString().trim();
          if(TextUtils.isEmpty(stringhost)){
              Toast.makeText(this, "所输内容为空，请确认后输入", LENGTH_SHORT).show();
              return;
          }
          if(TextUtils.isEmpty(stringkey)){
              Toast.makeText(this, "所输内容为空，请确认后输入", LENGTH_SHORT).show();
              return;
          }
          if(TextUtils.isEmpty(stringsecret)){
              Toast.makeText(this, "所输内容为空，请确认后输入", LENGTH_SHORT).show();
              return;
          }
          new Thread(){
              public void run(){
                  ArtemisConfig.host = stringhost;//"127.0.0.1:443"; // artemis网关服务器ip端口
                  ArtemisConfig.appKey = stringkey;//"29180881";  // 秘钥appkey
                  ArtemisConfig.appSecret = stringsecret;//"XO0wCAYGi4KV70ybjznx";// 秘钥appSecret
  
                  /**
                   * STEP2：设置OpenAPI接口的上下文
                   */
                  final String ARTEMIS_PATH = "/artemis";
  
                  /**
                   * STEP3：设置接口的URI地址
                   */
                  final String VechicleDataApi = ARTEMIS_PATH +"/api/fms/v3/human/findSnapHuman";
                  Map&lt;String,String&gt; path = new HashMap&lt;String,String&gt;(2){
                      {
                          put("https://",VechicleDataApi);
                      }
                  };
  
                  /**
                   * STEP4：设置参数提交方式
                   */
                  //String contentType = "application/json";
  
                  /**
                   * STEP5：组装请求参数
                   */
                  JSONObject jsonBody = new JSONObject();
                  try{
                      jsonBody.put("deviceCodes","-1");
                      jsonBody.put("sex",-1);
                      jsonBody.put("beginDate","2017-09-01 12:00:00");
                      jsonBody.put("endDate","2017-09-12 12:00:00");
                      jsonBody.put("similarityMin",0.1);
                      jsonBody.put("similarityMax",1);
                      jsonBody.put("picUrl", "http://10.33.44.61:6501/pic?=d82i649e*4ebi05f-646618-52c3ca0764e4cai5b1*=1d6s4*=6dpi*=1d3i4t2pe*m5i13=-1050e3-10z1cas=630bd1");
                      jsonBody.put("pageNo",1);
                      jsonBody.put("pageSize",12);
                  }catch(JSONException e){
                      e.printStackTrace();
                      Message message = Message.obtain();
                      message.what = ERROR;
                  }
                  String body = jsonBody.toString();
                  /**
                   * STEP6：调用接口
                   */
                  String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");// post请求application/json类型参数
                  Message message = Message.obtain();
                  message.what = SUCCESS;
                  message.obj = result;
                  FindURL fi = new FindURL();
                  fi.setUrl(result);
              }
          }.start();
      }
  }
  </code></pre>
  
  <p><strong>build.gradle:</strong></p>
  
  <pre><code>    apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "com.hikvision.open.app"
          minSdkVersion 16
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
      //useLibrary 'org.apache.http.legacy'
  
  }
  
  dependencies {
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      implementation 'com.android.support:support-annotations:28.0.0'
      implementation 'com.android.support:appcompat-v7:28.0.0'
      implementation 'com.android.support:design:28.0.0'
      implementation 'com.blankj:utilcode:1.20.3'
      implementation files('libs/artemis-http-client-1.0-SNAPSHOT.jar')
  }
  </code></pre>
  
  <p>When I use runOnUiThread to instead of the handler,the code:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      super.setContentView(R.layout.activity_main);
      Button mPreviewButton = (Button) findViewById(R.id.preview_button);
      mPreviewButton.setOnClickListener(MainActivity.this);
      Button mfindButton = (Button) findViewById(R.id.find_button);
      mfindButton.setOnClickListener(MainActivity.this);
      requestPermissions();
  
      host = findViewById(R.id.text_input_host);
      key = findViewById(R.id.text_input_key);
      secret = findViewById(R.id.text_input_secret);
  
      Toast.makeText(this, "请先获得地址，之后实时预览", LENGTH_LONG).show();
  }
  
  @Override
  public void onClick(View view) {
      if (view.getId() == R.id.preview_button) {
          startActivity(new Intent(this, PreviewActivity.class));
      } else if (view.getId() == R.id.find_button) {
          String stringhost = host.getText().toString().trim();
          String stringkey = key.getText().toString().trim();
          String stringsecret = secret.getText().toString().trim();
          if(TextUtils.isEmpty(stringhost)){
              Toast.makeText(this, "所输内容为空，请确认后输入", LENGTH_SHORT).show();
              return;
          }
          if(TextUtils.isEmpty(stringkey)){
              Toast.makeText(this, "所输内容为空，请确认后输入", LENGTH_SHORT).show();
              return;
          }
          if(TextUtils.isEmpty(stringsecret)){
              Toast.makeText(this, "所输内容为空，请确认后输入", LENGTH_SHORT).show();
              return;
          }
          MainActivity.this. runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  // refresh ui 的操作代码
                  ArtemisConfig.host = stringhost;//"127.0.0.1:443"; // artemis网关服务器ip端口
                  ArtemisConfig.appKey = stringkey;//"29180881";  // 秘钥appkey
                  ArtemisConfig.appSecret = stringsecret;//"XO0wCAYGi4KV70ybjznx";// 秘钥appSecret
  
                  /**
                   * STEP2：设置OpenAPI接口的上下文
                   */
                  final String ARTEMIS_PATH = "/artemis";
  
                  /**
                   * STEP3：设置接口的URI地址
                   */
                  final String VechicleDataApi = ARTEMIS_PATH +"/api/fms/v3/human/findSnapHuman";
                  Map&lt;String,String&gt; path = new HashMap&lt;String,String&gt;(2){
                      {
                          put("https://",VechicleDataApi);
                      }
                  };
  
                  /**
                   * STEP4：设置参数提交方式
                   */
                  //String contentType = "application/json";
  
                  /**
                   * STEP5：组装请求参数
                   */
                  JSONObject jsonBody = new JSONObject();
                  try{
                      jsonBody.put("deviceCodes","-1");
                      jsonBody.put("sex",-1);
                      jsonBody.put("beginDate","2017-09-01 12:00:00");
                      jsonBody.put("endDate","2017-09-12 12:00:00");
                      jsonBody.put("similarityMin",0.1);
                      jsonBody.put("similarityMax",1);
                      jsonBody.put("picUrl", "http://10.33.44.61:6501/pic?=d82i649e*4ebi05f-646618-52c3ca0764e4cai5b1*=1d6s4*=6dpi*=1d3i4t2pe*m5i13=-1050e3-10z1cas=630bd1");
                      jsonBody.put("pageNo",1);
                      jsonBody.put("pageSize",12);
                  }catch(JSONException e){
                      e.printStackTrace();
                      /*Message message = Message.obtain();
                      message.what = ERROR;*/
                      Toast.makeText(MainActivity.this, "查询错误，请检查无误后输入", LENGTH_SHORT).show();
                  }
                  String body = jsonBody.toString();
                  /**
                   * STEP6：调用接口
                   */
                  String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");// post请求application/json类型参数
                  /*Message message = Message.obtain();
                  message.what = SUCCESS;
                  message.obj = result;*/
                  Toast.makeText(MainActivity.this, "查询成功，请点击预览按钮", LENGTH_SHORT).show();
                  Toast.makeText(MainActivity.this, "返回信息：" + result, LENGTH_LONG).show();
                  FindURL fi = new FindURL();
                  fi.setUrl(result);
              }
          });
      }
  }
  
  
  /**
   * 获取手机存储读写权限
   */
  private void requestPermissions() {
      int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
      if (permissionCheck == PackageManager.PERMISSION_DENIED) {
          ActivityCompat.requestPermissions(this, (new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}), 10);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The new EXCEPTION has happened:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.hikvision.open.app, PID: 10719
  java.lang.NoSuchMethodError: No direct method &lt;init&gt;(Ljavax/net/ssl/SSLContext;)V in class Lorg/apache/http/conn/ssl/SSLSocketFactory; or its super classes (declaration of 'org.apache.http.conn.ssl.SSLSocketFactory' appears in /system/framework/framework.jar:classes3.dex)
      at com.hikvision.artemis.sdk.util.HttpUtil.sslClient(HttpUtil.java:499)
      at com.hikvision.artemis.sdk.util.HttpUtil.wrapClient(HttpUtil.java:478)
      at com.hikvision.artemis.sdk.util.HttpUtil.httpPost(HttpUtil.java:178)
      at com.hikvision.artemis.sdk.Client.execute(Client.java:53)
      at com.hikvision.artemis.sdk.ArtemisHttpUtil.doPostStringArtemis(ArtemisHttpUtil.java:182)
      at com.hikvision.open.app.MainActivity$1.run(MainActivity.java:151)
      at android.app.Activity.runOnUiThread(Activity.java:6281)
      at com.hikvision.open.app.MainActivity.onClick(MainActivity.java:99)
      at android.view.View.performClick(View.java:6897)
      at android.widget.TextView.performClick(TextView.java:12693)
      at android.view.View$PerformClick.run(View.java:26101)
      at android.os.Handler.handleCallback(Handler.java:789)
      at android.os.Handler.dispatchMessage(Handler.java:98)
      at android.os.Looper.loop(Looper.java:164)
      at android.app.ActivityThread.main(ActivityThread.java:6944)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
  </code></pre>
  
  <p>I need help!!!PLEASE!!</p>