1. ๋ฐœ์ƒ ์ƒํ™ฉ

Retrofit2๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Restํ†ต์‹ ์„ ํ•˜๋ ค๊ณ  ํ•  ๋•Œ, ์›น ์„œ๋ฒ„์— ์ ‘๊ทผ์„ ๋ชป ํ•œ๋‹ค๊ณ  ์ด์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค!

Call error: CLEARTEXT communication to xxx.xxx.xx not permitted by network security policy

 

 

2. ๋ฐœ์ƒ ์›์ธ

์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” API์ฃผ์†Œ, ์ด๋ฏธ์ง€์ฃผ์†Œ ๋“ฑ ๋„คํŠธ์›Œํฌ ๊ฒฝ๋กœ๊ฐ€ https๊ฐ€ ์•„๋‹Œ http๋กœ ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•œ ๋ฌธ์ œ๋ผ๊ณ  ํ•œ๋‹ค.

 

 

3. ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

1. ๊ฐ€์žฅ ์‰ฌ์šด ๋ฐฉ๋ฒ•์€ ์‚ฌ์šฉํ•˜๋Š” ๋„คํŠธ์›Œํฌ ์ฃผ์†Œ๋ฅผ https๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

 

2. ํ•˜์ง€๋งŒ, ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” ์„œ๋ฒ„๊ฐ€ https๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ์—๋Š” ์•„๋ž˜ ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜๋ฅผ ์ ์šฉํ•˜๋ฉด ๋œ๋‹ค.

 

2-1. network_security_config.xml ํŒŒ์ผ ์ƒ์„ฑ ํ›„, AndroidManifast.xml ์— ๋“ฑ๋กํ•˜๊ธฐ 

 

res/xml ๋””๋ ‰ํ„ฐ๋ฆฌ์— network_security_config.xml ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด ์ค€๋‹ค.

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">xxx.xxx.xxx</domain>
    </domain-config>
</network-security-config>

๊ทธ๋ฆฌ๊ณ  Manifast์— ํ•ด๋‹น ํŒŒ์ผ์„ config ํŒŒ์ผ๋กœ ์ง€์ •ํ•œ๋‹ค.

<application    
		...    
    android:networkSecurityConfig="@xml/network_security_config">

 

 

2-2. AndroidManifast.xml์˜ usesCleartextTraffic ์†์„ฑ ์„ค์ •

 

<application    
		...    
    android:usesCleartextTraffic="true">

 

 


์ฐธ๊ณ ์ž๋ฃŒ

https://gun0912.tistory.com/80

1. ๋ฐœ์ƒ ์ƒํ™ฉ

Mac ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค์—์„œ Private ํ”„๋กœ์ ํŠธ๋ฅผ Pullํ•˜๋Š” ์ƒํ™ฉ์—์„œ ํ•ด๋‹น ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

unable to read askpass response from 'ํ”„๋กœ์ ํŠธ ๊ฒฝ๋กœ' 
could not read Username for 'https://github.com': Device not configured

 

 

2. ๋ฐœ์ƒ ์›์ธ

This commonly happens in an environment where you are invoking git from some sort of gui tool and no appropriate credentials helper has been configured.

๋ฒˆ์—ญ์„ ํ•ด๋ณด๋ฉด GUI๋„๊ตฌ์—์„œ Git์„ ํ˜ธ์ถœํ•˜๊ณ  ์ ์ ˆํ•œ ์ž๊ฒฉ ์ฆ๋ช… ๋„์šฐ๋ฏธ๊ฐ€ ๊ตฌ์„ฑ๋˜์ง€ ์•Š์€ ํ™˜๊ฒฝ์—์„œ ์ผ๋ฐ˜์ ์œผ๋กœ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์—๋Ÿฌ๋ผ๊ณ  ํ•œ๋‹ค.

 

 

3. ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

1. Android Preference > Version Control > GitHub

 

์•ˆ๋“œ๋กœ์ด๋“œ ํ”„๋กœ์ ํŠธ์— ์—ฐ๊ฒฐํ•ด ๋†“์€ ๊ณ„์ •์„ ํ™•์ธํ•ด ๋ณด๋‹ˆ, ์ด ์ „์— ๋ฐœ๊ธ‰๋ฐ›์€ Token์ด ๋งŒ๋ฃŒ๋˜์–ด์„œ Bad Credencial ํ‘œ์‹œ๊ฐ€ ๋˜์–ด ์žˆ์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ผ๋‹จ Git ๊ณ„์ •์„ ๋‹ค์‹œ ๋“ฑ๋กํ•˜๊ณ  ์ฒดํฌ ์•„์ด์ฝ˜์œผ๋กœ Default ๊ณ„์ • ์„ค์ •์„ ํ•ด์คฌ๋‹ค.

 



 

2. Android Preference > Version Control > Git

 

ํ•˜๋‹จ์— ์žˆ๋Š” Use credential helper ๋ฅผ ์ฒดํฌํ•ด์คฌ๋‹ค. ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค๋ฅผ ์žฌ์‹คํ–‰ํ•˜๊ณ  ํ”„๋กœ์ ํŠธ๋ฅผ ์ •์ƒ์ ์œผ๋กœ PULLํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

 

 


์ฐธ๊ณ ์ž๋ฃŒ

https://stackoverflow.com/questions/40274484/fatal-could-not-read-username-for-https-github-com-device-not-configured

1. ๋ฐœ์ƒ ์ƒํ™ฉ

private val moshi = Moshi.Builder()
    .add(KotlinJsonAdapterFactory())
    .build()

private val retrofit = Retrofit.Builder()
    .addConverterFactory(MoshiConverterFactory.create(moshi))
    .baseUrl(BASE_URL)
    .build()

REST ํ†ต์‹ ์œผ๋กœ ์›น ์„œ๋ฒ„์—์„œ ๋ฐ›์€ JSON ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์„œ ์•ˆ๋“œ๋กœ์ด๋“œ Moshi ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•  ๋•Œ, ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค!

Use jsonreader.setlenient(true) to accept malformed json at path $[0].null

 

 

2. ๋ฐœ์ƒ ์›์ธ

์—ด์‹ฌํžˆ ๊ตฌ๊ธ€๋ง์„ ํ•ด๋ณธ ๊ฒฐ๊ณผ...

Retrofit ๋นŒ๋“œํ•  ๋•Œ ์‚ฌ์šฉํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ JSON ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์„ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ๋ผ๊ณ  ํ•œ๋‹ค.

 

 

3. ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

  • Moshi๋กœ Retrofit์„ ๋นŒ๋“œํ•˜๋Š” ๊ฒฝ์šฐ : asLenient()
private val moshi = Moshi.Builder()
    .add(KotlinJsonAdapterFactory())
    .build()

private val retrofit = Retrofit.Builder()
    .addConverterFactory(MoshiConverterFactory.create(moshi).asLenient())
    .baseUrl(BASE_URL)
    .build()

 

  • GSON์œผ๋กœ Retrofit์„ ๋นŒ๋“œํ•˜๋Š” ๊ฒฝ์šฐ : setLenient()
private val gson : Gson = GsonBuilder()
    .setLenient()
    .create()

private val retrofit = Retrofit.Builder()
    .baseUrl(API_URL)
    .client(client)
    .addConverterFactory(GsonConverterFactory.create(gson))
    .build()

 


์ฐธ๊ณ ์ž๋ฃŒ

https://github.com/square/moshi/issues/132

https://bacassf.tistory.com/103

+ Recent posts