标签: android-4.0.3-ice-cream-sandwich

Javax.net.ssl.SSLHandshakeException:javax.net.ssl.SSLProtocolException:SSL握手中止:SSL库失败,通常是协议错误

我试图在android中运行以下代码

URLConnection l_connection = null;
        // Create connection
        uzip=new UnZipData(mContext);
        l_url = new URL(serverurl);

        if ("https".equals(l_url.getProtocol())) {
            System.out.println("<<<<<<<<<<<<< Before TLS >>>>>>>>>>>>");
            sslcontext = SSLContext.getInstance("TLS");
            System.out.println("<<<<<<<<<<<<< After TLS >>>>>>>>>>>>");
            sslcontext.init(null,
                    new TrustManager[] { new CustomTrustManager()},
                    new java.security.SecureRandom());
            HttpsURLConnection
                    .setDefaultHostnameVerifier(new CustomHostnameVerifier());
            HttpsURLConnection.setDefaultSSLSocketFactory(sslcontext
                    .getSocketFactory());

            l_connection = (HttpsURLConnection) l_url.openConnection();
            ((HttpsURLConnection) l_connection).setRequestMethod("POST");
        } else {
            l_connection = (HttpURLConnection) l_url.openConnection();
            ((HttpURLConnection) l_connection).setRequestMethod("POST");
        }
        /*System.setProperty("http.agent", "Android_Phone");*/


        l_connection.setConnectTimeout(10000);
        l_connection.setRequestProperty("Content-Language", "en-US");
        l_connection.setUseCaches(false);
        l_connection.setDoInput(true);
        l_connection.setDoOutput(true);
        System.out.println("<<<<<<<<<<<<< Before Connection >>>>>>>>>>>>");
        l_connection.connect();
Run Code Online (Sandbox Code Playgroud)

l_connection.connect(),它给出了这个SSLhandshakeException.有时候它有效,但大部分时间它都有例外.它只发生在Android 4.0模拟器上.我在Android 4.4和5.0上测试过,它运行正常.可能是什么原因造成的?请帮忙

堆栈跟踪

    04-28 15:51:13.143: W/System.err(2915): javax.net.ssl.SSLHandshakeException: …
Run Code Online (Sandbox Code Playgroud)

ssl android sslhandshakeexception android-4.0.3-ice-cream-sandwich

84
推荐指数
5
解决办法
10万
查看次数

无法使用Android 4.0.3版创建模拟器

我需要用Android 4.0.3测试我的Android应用程序,但我无法用这个Android版本创建一个模拟器.请查看以下截图以获取更多详细信息:

安装版本4.0.3的Intel x86系统映像: 安装版本4.0.3的Intel x86系统映像

选择系统映像时没有4.0.3版本的选项: 选择系统映像时没有4.0.3版本的选项

已经尝试过没有运气了:

  1. 重启Android Studio
  2. 将x86文件夹从system-images/android-15/default移动system-images/android-15文件夹

我该如何解决这个问题?

编辑:

正如BrentM所建议的那样,我尝试使用android命令行工具创建它.它已成功创建,但当我尝试从Android Studio编辑它时,它会出错:指定的图像文件必须是有效的图像文件.

系统中图像文件的地址:/ Android/Sdk/system-images/android-15/x86

截图: 在此输入图像描述

android android-emulator android-studio android-4.0.3-ice-cream-sandwich

10
推荐指数
1
解决办法
1494
查看次数