关于新浪微博 weibo4j.model.MySSLSocketFactory.createSocket(MySSLSocketFactory.java:78)

阅读更多

 

07-10 23:31:41.905: E/AndroidRuntime(32441): FATAL EXCEPTION: main
07-10 23:31:41.905: E/AndroidRuntime(32441): java.lang.NullPointerException
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
weibo4j.model.MySSLSocketFactory.createSocket(MySSLSocketFactory.java:78)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
weibo4j.http.HttpClient2.httpRequest(HttpClient2.java:399)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
weibo4j.http.HttpClient2.post(HttpClient2.java:305)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
weibo4j.Oauth.getAccessTokenByCode(Oauth.java:76)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
weibo4j.WeiboOauth2.getAccessToken(WeiboOauth2.java:66)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
com.kandian.user.WeiboWebViewHelper$1.onPageFinished(WeiboWebViewHelper.java:114)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:285)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
android.os.Handler.dispatchMessage(Handler.java:99)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
android.os.Looper.loop(Looper.java:143)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
android.app.ActivityThread.main(ActivityThread.java:5068)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
java.lang.reflect.Method.invokeNative(Native Method)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
java.lang.reflect.Method.invoke(Method.java:521)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-10 23:31:41.905: E/AndroidRuntime(32441): 	at
dalvik.system.NativeStart.main(Native Method)

 

 刚开始我以为是未导入HttpClient的jar包!但是,我用手机多次是没问题的.但是,前几天调试的时候就会出现这样的问题.

不知所以然!

因为不知道新浪的的jar,是我编译的.但是又不是很好测试.因为只有我总监的手机才会出现这样类似的问题!

 

今天我们组长发邮说问题已经解决.故此与大家分享下.

 

解决办法如下:

 

 

sina官方放的weibo4j_oauth2接口是https,所以官方Example按标准写的是SSLContext.getInstance("SSL"); 2.2及以下版本SDK不支持这种方法,将所引用的源码改为SSLContext.getInstance("TLS")就行了。

 

 

在这里也十分感谢组长,旭哥!

你可能感兴趣的:(SSLContext,SSL,TLS)