admin管理员组文章数量:1429645
I'm implementing the Retrofit library into an Android Studio project. Then my goal is calling an external API call from my Android app. Now I implemented Retrofit in my project (using the Kotlin language) without sync/compile errors.
When I run my app from the Android Studio emulator and I call a sample API, I obtain the following error:
javax.ssl.SSLHandshakeException: Chain validation failed
I think I'm having some certificate issue, but I don't know how fix it.
I'm implementing the Retrofit library into an Android Studio project. Then my goal is calling an external API call from my Android app. Now I implemented Retrofit in my project (using the Kotlin language) without sync/compile errors.
When I run my app from the Android Studio emulator and I call a sample API, I obtain the following error:
javax.ssl.SSLHandshakeException: Chain validation failed
I think I'm having some certificate issue, but I don't know how fix it.
Share Improve this question edited Nov 28, 2024 at 13:44 gre_gor 6,72811 gold badges76 silver badges90 bronze badges asked Nov 28, 2024 at 10:05 TinoTino 13 bronze badges 3- 1 Hey, try searching your answers here stackoverflow/a/53297674/17552167 , or else try to cold boot the emulator if you are using it. Or try to check if the API which you are calling is getting called on postman or chrome. If not then you need to fix the URL. Also, if nothing works try to provide your code and also try to change the version of dependency version. – Vishal Shah Commented Nov 28, 2024 at 11:52
- I searched in stackoverflow/a/53297674/17552167, I restarted the emulator, the API is ok because from Postman it works fine, but nothing helps... – Tino Commented Nov 28, 2024 at 16:09
- Please provide enough code so others can better understand or reproduce the problem. – melvio Commented Nov 28, 2024 at 17:51
1 Answer
Reset to default 0I resolved in this way:
- In my API now I use http instead of https
- I created the resource file: res/xml/network_security_config.xml, with:
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="true">api.example</domain> </domain-config> </network-security-config>
- I edited my AndroidManifest.xml:
<application android:networkSecurityConfig="@xml/network_security_config" ... </application>
Now it works!
本文标签: kotlinImplementing Retrofit on Android StudioStack Overflow
版权声明:本文标题:kotlin - Implementing Retrofit on Android Studio - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745517208a2661612.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论