在Android的LinkedIn集成中,与服务提供商的通信失败

时间:2015-05-08 05:59:32

标签: android login linkedin

我正在尝试将LinkedIn登录集成到我的Android应用中。我成功整合了它,它工作正常。但奇怪的是,当我今天再次运行我的应用程序时,我正在与服务提供商进行通信失败错误。我检查了我的消费者和密钥。但没有问题。我也没有改变我的代码。还有一件事,在收到此错误后,我创建了一个只有LinkedIn登录的不同项目。但这很好。搜索谷歌和stackoverflow,一些人说要修复日期和时间。我也做了..但仍然是同样的问题。如果有人有解决方案,请告诉我。这是我的logcat输出:

com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: null
            at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:205)
            at com.example.v4web.genesx.LinkedInDialog.setWebView(LinkedInDialog.java:58)
            at com.example.v4web.genesx.LinkedInDialog.onCreate(LinkedInDialog.java:45)
            at android.app.Dialog.dispatchOnCreate(Dialog.java:373)
            at android.app.Dialog.show(Dialog.java:274)
            at com.example.v4web.genesx.Login.linkedInLogin(Login.java:402)
            at com.example.v4web.genesx.Login.access$100(Login.java:45)
            at com.example.v4web.genesx.Login$4.onClick(Login.java:227)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: null
            at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:214)
            at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
            at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:196)
            at com.example.v4web.genesx.LinkedInDialog.setWebView(LinkedInDialog.java:58)
            at com.example.v4web.genesx.LinkedInDialog.onCreate(LinkedInDialog.java:45)
            at android.app.Dialog.dispatchOnCreate(Dialog.java:373)
            at android.app.Dialog.show(Dialog.java:274)
            at com.example.v4web.genesx.Login.linkedInLogin(Login.java:402)
            at com.example.v4web.genesx.Login.access$100(Login.java:45)
            at com.example.v4web.genesx.Login$4.onClick(Login.java:227)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: android.os.NetworkOnMainThreadException
            at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
            at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
            at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
            at java.net.InetAddress.getAllByName(InetAddress.java:215)
            at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29)
            at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232)
            at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124)
            at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:272)
            at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
            at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
            at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
            at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
            at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:25)
            at oauth.signpost.basic.DefaultOAuthProvider.sendRequest(DefaultOAuthProvider.java:48)
            at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:177)
            at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
            at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:196)
            at com.example.v4web.genesx.LinkedInDialog.setWebView(LinkedInDialog.java:58)
            at com.example.v4web.genesx.LinkedInDialog.onCreate(LinkedInDialog.java:45)
            at android.app.Dialog.dispatchOnCreate(Dialog.java:373)
            at android.app.Dialog.show(Dialog.java:274)
            at com.example.v4web.genesx.Login.linkedInLogin(Login.java:402)
            at com.example.v4web.genesx.Login.access$100(Login.java:45)
            at com.example.v4web.genesx.Login$4.onClick(Login.java:227)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)

1 个答案:

答案 0 :(得分:2)

试试这个

setContentView() onCreate()之后添加以下功能。

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
        }