어제 앱을 개발 중 glide v4를 사용하여 웹에 있는 그림을 load 하였는데, 아래와 같은 예외를 주며 동작을 하지 않았습니다.
com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
There was 1 cause:
java.io.IOException(Cleartext HTTP traffic to ~~~~ not permitted)
call GlideException#logRootCauses(String) for more detail
처음에는 glide4로 버전업을 하면서 뭔가 바뀐 것이 있나 싶어서 glide 문서를 뒤지고, 관련 코드들을 보았는데 특별한 것이 없었습니다. 그림을 load 할 대상 주소를 보던 중 문득 예전에 안드로이드가 https 가 아닌 http 프로토콜 접속을 제한한다는 구글 블로그 내용이 떠올랐습니다.
[그림1] google develops korea blog 내용 발췌
그래서 구글 검색을 해보니 실제로 이 예외는 안드로이드9(APL Lv 28) 부터 강화된 네트워크 보안정책으로 인한 오류였습니다.
몇몇 사이트를 돌아다니며, 확인해보니 3가지 해결방법이 있었습니다.
저는 1번의 방법으로 해결하였습니다. 다른 방법도 함께 소개하오니 많은 도움되셨으면 합니다.
1. AndroidManifest.xml 파일의 <application> 부분에 android:usesCleartextTraffic="true" 로 설정
cleartext HTTP와 같은 cleartext 네트워크 트래픽을 사용할지 여부를 나타내는 flag로 이 플래그가 flase 로 되어 있으면, 플랫폼 구성 요소 (예 : HTTP 및 FTP 스택, DownloadManager, MediaPlayer)는 일반 텍스트 트래픽 사용에 대한 앱의 요청을 거부하게 됩니다.
이 flag를 설정하게 되면 모든 cleartext 트래픽은 허용처리가 됩니다.
2. networkSecurityConfig 파일을 생성하고, AndroidManifest 에 등록
res/xml/network_security_config.xml 아래와 같이 추가합니다.
<domain includeSubdomains="true">ebookfrenzy.com</domain> 등록된 도메인은 https 가 아니어도 허용이 됩니다.
1. Download the crx file and unpack the extension using your favorite decompresser. Take note of the directory where you placed it.
2. Open the extension page, activate "Developer Mode"
3. Click "Load unpacked extension..."
4. Search trough your directory tree for the directory where you unpacked your extension and click OK. If your extension is called "my extension" then select "my extension" directory.
Advantages: You don't have to install anything else. Disadvantages: Chrome nags you to disable the extension each start up.
- from release channel
Install the Dev or Canary version of Chrome. Just go to the corresponding link and install the browser. Note that the Canary version will install a parallel version of Chrome which will be independent.
Advantage: No nagging, you get the most newest features earlier. Disadvantages: You also get all the bugs earlier. Installing Canary effectively uses the double disk space than a single installation of Chrome and also you have to migrate all your extensions over
- 크롬 확장앱 crx를 풀어서 로드시에 설치가 안 되는 경우는 대부분 crx 파일을 만들 때 manifest file format을 지키지 않아서 생기는 문제입니다. "manifest_version": 2 은 반드시 정의 하도록 하고 있습니다. 이경우에는 manifest.json에 추가 하면 됩니다. https://developer.chrome.com/extensions/manifest
배포시 가장 큰 골치덩어리중 하나는 AndroidManifest.xml 파일 수정문제일 것이다. Android Plugin을 만들어서 넣자니 짜증나고... 그럴때 간단하게 AndroidManifest.xml 파일을 수정할 수 있는 방법을 공개한다.
프로젝트 Root폴더에 보면 "Temp" 폴더가 생성되어 있을텐데 거길 가만히 보면 "StagingArea"라는 폴더가 보인다. 여기로 들어가면 다음과 같이 폴더가 구성되어 있다.
빌드에서 사용될 각종 Resource 파일들이 보일텐데 이중에 필요한건 AndroidManifest.xml 파일과 res 폴더 두개이다. 이 2개를 선택해서 CTRL+C 해서 복사하고 유니티로 돌아와서 "Plugins" 폴더를 만든다음 다시 "Android"폴더를 만들고 거기에 복사해 넣자.
이제 복사한 AndroidManifest.xml 파일을 열어서 마음대로 주무르면 됨. 끝!