java.io.IOException : No authentication challenges found

前端 未结 5 1153
长发绾君心
长发绾君心 2020-11-27 18:49

I am newbie to android and this is my first project on android. I am struggling with \"authentication\" problem for more than a day. I tried several options but none of them

5条回答
  •  误落风尘
    2020-11-27 19:09

    Had the same issue on some old devices (Huawei Y330-U11 for instance). Correct way to fix it is to fix it server side as mentioned in the most popular answer.

    However, it's really disappointing that the issue occurs only on some devices. And I believe it happens due to different implementations of "UrlConnection". Different Android versions - different "UrlConnection" implementations.

    So, you might want to fix it by using the same "UrlConnection" everywhere. Try to use okhttp and okhttp-urlconnection.

    Here is the way to add those libs to your gradle build:

    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
    

    It solved the problem for me on those outdated devices. (I had to use OkClient for Retrofit RestAdapter)

    P.S. Latest Androids at time of writing use old version of OKHTTP library internally as "UrlConnection" implemetation (with updated package names), so it seems to be quite solid thing

提交回复
热议问题