We found out that this problem was caused by big textures loaded at the same time.
After removing these big textures the game started up without any problems.
So for everyone that has the same problem.
Check your big textures and check when they are being loaded and try to load.
----
2. 동시에 2번의 File IO
-> 동시에 File IO 안되도록 수정
----
We found out that this problem was caused by using PlayerPrefs.Save() twice at the same time on two different functions, also we had used File.write() at that time. when we save and write files at a different time, this issue solved.
Unity 2019에서 Android API 29를 쓰다가 API 30으로 올려서 Android SDK API 30을 받으려고 하는데 실패하고 아래와 같은 에러메시지가 떴다.
Exception: Unable to install additional SDK platform. Please run the SDK Manager manually to make sure you have the latest set of tools and the required platforms installed.
C:/Program Files/Unity/Hub/Editor/2019.4.22f1/Editor/Data/PlaybackEngines/AndroidPlayer\SDK\tools\bin\sdkmanager.bat "platforms;android-30", exit code 1
그래서 에러메시지에 있는 sdkmanager.bat 파일을 열어보니 JAVA_HOME 환경변수를 쓰고 있다.
요즘 Unity는 OpenJDK를 내장해서 각자 버전별로 쓰고 있기 때문에 환경변수를 만들지 않는데 내부 소스(sdkmanager.bat)에선 여전히 쓰게 해놓은 건 문제인 듯 하다.
아무튼 sdkmanager.bat가 돌려면 JAVA_HOME 환경변수를 만들어 줘야되니,
유니티 엔진 내부에 있던 OpenJDK를 C:\ 최상위에 하나 복사하고 JAVA_HOME으로 환경변수 만들어주니 잘 작동한다.
[유니티 엔진 내부 OpenJDK 위치] C:\Program Files\Unity\Hub\Editor\2019.4.22f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
/Users/jim/Desktop/workspace/project/project/Temp/gradleOut/launcher/build/intermediates/merged_manifests/release/AndroidManifest.xml:52: AAPT: error: unexpected element found in
Unity Application.persistentDataPath의 경로는 Android의 버전과 Write Access에 따라 달라짐
Android에서 Application.persistentDataPath가 돌려주는 값이 Write Access에 따라 달라지기에 조사해봤습니다. Unity 5.3.6에서 돌려주는 경로에 사양변경이 있었으므로, Unity 5.3.6 이전 버전에서 작성한 애플리케이션을 Unity 5.3.6 이후로 버전업할 때 주의를 기울이지 않으면 데이터가 사라질 위험이 있습니다. 갖고 있는 Android기기와 Unity 4.7.2f1, 5.3.6f1에서 검증했습니다.
외부 저장소라고 불리는 영역이지만 SD 카드가 아니라 빼낼 수 없게 내장된 저장소를 참조하는 기기도 있음. Android 4.4 이후에는 권한을 요구하지 않고 외부 저장소에 읽고 쓰기가 가능.
Windows PC를 예로 들면 오래된 Android 기기 C드라이브: 내장 드라이브 (Android 내부 저장소) D드라이브: USB로 접속된 외장 하드디스크 (Android 외부 저장소) 최신 Android 기기 C드라이브: 내장 드라이브 파티션 0 (Android 내부 저장소) D드라이브: 내장 드라이브 파티션 1 (Android 외부 저장소) E드라이브: USB로 접속된 외장 하드디스크 (Android 외부 저장소)
WRITE_EXTERNAL_STORAGE를 추가한 경우, Android 6 이후에는 Permissions Storage의 물음에서 ALLOW를 선택할 때까지는 기동할 때마다 물어봄. ALLOW를 선택한 후에도 Application의 설정에서 Permissions Storage 허가의 변경은 가능. 4.1.2 (200SH): Write Access: External (SDCard) 만이 SD 카드의 경로를 돌려줌. SD 카드를 뽑았을 경우에는 Internal Only와 같은 경로를 돌려줌. 그 외에는 내부 저장소를 참조. Unity 4.7.2 Android 6.0.1는 Permissions Storage의 허가 유무로 돌려주는 경로가 달라짐. Unity 5.3.6 Android 4.4 이후는 Permissions Storage의 허가 유무와 상관없이 돌려주는 값이 같음.
Unity 4.7.2에서 작성한 애플리케이션에서 Application.persistentDataPath에 저장한 데이터를 Unity 5.3.6에서 작성한 애플리케이션에서 덮어씌웠을 경우 읽어들일 수 있을까?
UnauthorizedAccessException: Access to the path "/storage/sdcard0/Android/data/{package name}/files/{file name}" is denied. external-storage를 internal-storage에 복사하려고 해서 실패?
UnauthorizedAccessException: Access to the path "/storage/sdcard0/Android/data/{package name}/files/{file name}" is denied. external-storage를 internal-storage에 복사하려고 해서 실패?
Internal Only, External (Permissions Storage: DENY)일 때에는 internal-storage를 external-storage에 복사한 후에 읽어들이도록 되어 있음. external-storage로 변경해도 internal-storage는 복사 시점 그대로 변경은 되지 않음.
정리
Internal Only -> External (SDCard)로의 변경은 데이터를 이어받지 못하는 경우가 있음. 그 경우, 수동으로 /data/data/{package name}/files/ 를 복사하는 등의 대응이 필요. External (SDCard) -> Internal Only로의 변경은 오래된 Android 기기기에서 정상으로 처리되지 않을 가능성이 있음. Android 6 이후에는 Unity 4.7.2의 Write Access가 어느쪽이든 Unity 5.3.6의 Write Access: Internal Only로 해두면 데이터를 이어받아 읽고 쓰기가 가능.