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로 해두면 데이터를 이어받아 읽고 쓰기가 가능.
2020-02-18 01:09:43.567 4919-11220/? E/SignInAuthenticator: **** **** APP NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY GAME SERVICES **** This is usually caused by one of these reasons: **** (1) Your package name and certificate fingerprint do not match **** the client ID you registered in Developer Console. **** (2) Your App ID was incorrectly entered. **** (3) Your game settings have not been published and you are **** trying to log in with an account that is not listed as **** a test account. **** **** To help you debug, here is the information about this app **** Package name : 모자이크 **** Cert SHA1 fingerprint: 모자이크 **** App ID from manifest : 모자이크 **** **** Check that the above information matches your setup in **** Developer Console. Also, check that you're logging in with the **** right account (it should be listed in the Testers section if **** your project is not yet published). **** **** For more information, refer to the troubleshooting guide: **** http://developers.google.com/games/services/android/troubleshooting ****
This repository allows to send local notification from unity project on android devices.
Features
you can send local notification in android
you can schedule sending notification for some time in future
you can send notification having big picture style
Issues
not all android notification features are supported
Sample code
Publisher publisher = PublisherManager.Instance.CreatePublisher(channelId, channelName, channelDescription); // put your icon png file in Plugins/Android/UnityLocalNotification/res/drawable Notification notification = new Notification() .SmallIconName("test_icon") .Title("My notif title") .Message("This is a test notification message"); publisher.Publish(notification);
READ_PHONE_STATE Permission isn’t in my Manifest or Plugins!
Unity automatically adds theREAD_PHONE_STATEpermission into builds when either:
Your scriptscontain code which require the permission.
Thetarget SDK version isn’t set(or set below 4)which causes the manifest merger to assume the SDK version is lower than 4 and the system will implicitly grant the READ_PHONE_STATE permission to the app.(in later versions of Unity 5 and Unity 2017 the target SDK version is now set in the editor making managing it much easier)
You have aplugin in your project which has its own manifest filerequesting the permission(the manifest can be contained within your jar or aar files, they’re not always simply in your project) –Note that if a plugin is requesting a permission then it’s probably required and may cause issues if removed, check the plugin documentation if you’re unsure!
Code which causes Unity to automatically add the permission
In the case of your scripts containing code which need the permission. Unity automatically adds the permission when using functions which require it.
SomeSystemInfoproperties such asSystemInfo.deviceUniqueIdentifierrequire the READ_PHONE_STATE permission so referencing it in a script will force Unity to add it.
As an alternative to SystemInfo.deviceUniqueIdentifier when needing a unique device identifier and it’s not important to keep it the same between wiping save data. Consider generating a unique value based onSystem.DateTime.Now.Ticksand storing in the playerprefs instead.
Why am I asked to allow/deny the permission at app launch?
Starting with Android 6.0 the user was given more control over permissions apps were allowed to use at runtime; rather than a blanket list of confusing permission being included with the app at installation. Permissions which are prompted for the user to allow are classified asdangerous permissionsas they can allow the app to access sensitive data.(in this case READ_PHONE_STATE can allow reading of the phone number, call statuses or listphone accountsregistered on the device)
If you want to manually control when the permissions are requested at runtime rather than all dangerous permissions just being prompted at startup then you can add: <meta-data android:name=”unityplayer.SkipPermissionsDialog” android:value=”true” /> Between the <application> tags of your manifest file.
With the permission dialog skipped all dangerous permissions will remain defaulted as denied! But this allows you to request permissions manually when you need them, rather than all at once at app launch.(However note that you’ll either need to write a Java plugin yourself to control this or find an already built plugin from the store such asAndroid Buddywhich fits this exact purpose!)
Learn more about the READ_PHONE_STATE android permission!