私は自分のプロジェクトでRetrofit 2を正常に実装しましたが、すべて正常に機能しています。しかし、インターネットが存在しなければ、アプリケーションは失敗したリクエストに対して複数のリクエストを送信しています。これにより、生成され続ける失敗した要求のスタックが作成され、アプリケーションがハングする結果になります。インターネットが接続されていないと、Retrofitは再試行を続けます
私はそのような動作の原因を理解していません。
02-01 16:16:08.812 27970-28054/? D/OkHttp: --> GET https://api.newsapi.in/v1/stories/category/india?nobody=true&skip=0&limit=10 http/1.1
02-01 16:16:08.812 27970-28054/? D/OkHttp: --> END GET
02-01 16:16:08.812 27970-28054/? D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:08.912 27970-28054/? D/OkHttp: --> GET https://api.newsapi.in/v1/stories/category/international?nobody=true&skip=0&limit=10 http/1.1
02-01 16:16:08.912 27970-28054/? D/OkHttp: --> END GET
02-01 16:16:08.912 27970-28054/? D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:08.922 27970-27970/? E/NewsListFragment: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:08.922 27970-27970/? E/NewsListFragment: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:08.942 27970-27979/? I/dalvikvm: Jit: resizing JitTable from 4096 to 8192
02-01 16:16:09.042 27970-28054/? D/OkHttp: --> GET https://api.newsapi.in/v1/stories/category/india?nobody=true&skip=0&limit=10 http/1.1
02-01 16:16:09.042 27970-28054/? D/OkHttp: --> END GET
02-01 16:16:09.042 27970-28054/? D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.142 27970-28054/? D/OkHttp: --> GET https://api.newsapi.in/v1/stories/category/international?nobody=true&skip=0&limit=10 http/1.1
02-01 16:16:09.142 27970-28054/? D/OkHttp: --> END GET
02-01 16:16:09.142 27970-28054/? D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.152 27970-27970/? E/NewsListFragment: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.162 27970-27970/? E/NewsListFragment: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.282 27970-28054/? D/OkHttp: --> GET https://api.newsapi.in/v1/stories/category/india?nobody=true&skip=0&limit=10 http/1.1
02-01 16:16:09.282 27970-28054/? D/OkHttp: --> END GET
02-01 16:16:09.282 27970-28054/? D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.402 27970-28054/? D/OkHttp: --> GET https://api.newsapi.in/v1/stories/category/international?nobody=true&skip=0&limit=10 http/1.1
02-01 16:16:09.402 27970-28054/? D/OkHttp: --> END GET
02-01 16:16:09.402 27970-28054/? D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.412 27970-27970/? E/NewsListFragment: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.432 27970-27970/? D/dalvikvm: GC_FOR_ALLOC freed 2592K, 13% free 21331K/24320K, paused 27ms, total 27ms
02-01 16:16:09.442 27970-27970/? E/NewsListFragment: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.552 27970-28054/? D/OkHttp: --> GET https://api.newsapi.in/v1/stories/category/india?nobody=true&skip=0&limit=10 http/1.1
02-01 16:16:09.552 27970-28054/? D/OkHttp: --> END GET
02-01 16:16:09.552 27970-28054/? D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.662 27970-28054/? D/OkHttp: --> GET https://api.newsapi.in/v1/stories/category/international?nobody=true&skip=0&limit=10 http/1.1
02-01 16:16:09.662 27970-28054/? D/OkHttp: --> END GET
02-01 16:16:09.662 27970-28054/? D/OkHttp: <-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.662 27970-27970/? E/NewsListFragment: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
02-01 16:16:09.672 27970-27970/? E/NewsListFragment: java.net.UnknownHostException: Unable to resolve host "api.newsapi.in": No address associated with hostname
私はretrofitが再試行しているとは思わない。ほとんどあなたは何度も何度もリクエストしています – Blackbelt