블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2862)
Unity3D (899)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (192)
협업 (65)
3DS Max (3)
Game (12)
Utility (142)
Etc (99)
Link (34)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (16)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (20)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

READ_PHONE_STATE Permission isn’t in my Manifest or Plugins!

Unity automatically adds the READ_PHONE_STATE permission into builds when either:

  • Your scripts contain code which require the permission.
  • The target 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 a plugin in your project which has its own manifest file requesting 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.

Some SystemInfo properties such as SystemInfo.deviceUniqueIdentifier require 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 on System.DateTime.Now.Ticks and 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 as dangerous permissions as 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 list phone accounts registered 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 as Android Buddy which fits this exact purpose!)

Learn more about the READ_PHONE_STATE android permission!

You can read more about the READ_PHONE_STATE permission on the android developer site at https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_STATE

 

[출처]

https://www.unity3dtips.com/read_phone_state-permission-android/

 

Remove READ_PHONE_STATE Permission Unity Android - Unity3d Tips

How to remove the READ_PHONE_STATE permission in your Unity Android apps and find the cause! Alternatively prompt the permission later than app startup!

www.unity3dtips.com

 

반응형
Posted by blueasa
, |

Easy Way

I think this easier approach applies if your Unity project is being built with gradle. If it isn't, here is one more reason to upgrade.

Also, a big shout-out to an article called, Hey, Where Did These Permissions Come From?)

  1. Build Your Project
  2. Open the file /path/to/my/project/Temp/gradleOut/build/outputs/logs/manifest-merger-release-report.txt
  3. Profit!
  4. Search the file for the name of your permission, and it'll show you where it came from.

Here is part of the file, where I'm looking for the WRITE_EXTERNAL_STORAGE permission.

uses-permission#android.permission.WRITE_EXTERNAL_STORAGE ADDED from /Users/clinton/Projects/<<ProjectName>>/Temp/gradleOut/src/main/AndroidManifest.xml:7:3-79 MERGED from [gradleOut:IronSource:unspecified] /Users/clinton/Projects/<<ProjectName>>/Temp/gradleOut/IronSource/build/intermediates/bundles/default/AndroidManifest.xml:13:5-81 android:name ADDED from /Users/clinton/Projects/<<ProjectName>>/Temp/gradleOut/src/main/AndroidManifest.xml:7:20-76

Hard Way

There are three ways permissions get added to your project.

  1. They are specified in an Android Manifest file.
  2. They are specified in library (a .aar file).
  3. Unity adds the permission when you use a certain feature. (Added)

My examples use command-line tools on a Mac. I don't know Windows equivalents, but it is possible to find and run unix tools there (using the linux subsystem for windows 10, cygwin, custom binaries, etc.)

1. Find all permissions used in (uncompressed) Android Manifests.

cd /path/to/my/project/Assets grep -r "uses-permission" --include "AndroidManifest.xml" .

This will find all files named AndroidManifest in the current folder (.) or any of its subfolders (-rtells it to search recursively) and spit out any line with the words 'uses-permission'.

In my current project, I get output something like this:

./Plugins/Android/AndroidManifest.xml: <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> ./Plugins/Android/AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> ./Plugins/Android/AndroidManifest.xml: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> ./Plugins/Android/AndroidManifest.xml: <uses-permission ./Plugins/Android/IronSource/AndroidManifest.xml: <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> ./Plugins/Android/IronSource/AndroidManifest.xml: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

2. Find the permissions required in Android Libraries

Your project likely contains android libraries (.aar files) and java archives (.jar files). Some android libraries contain an android manifest and specify permissions needed to use the library. (I don't think .jar files actually do this, but .aar files absolutely do). Both .aar and .jar files are .zip files, with a different extension and with specific metadata in specific places.

Find them by running:

find . -iname "*.?ar" -print -exec zipgrep "uses-permission" "{}" "AndroidManifest.xml" ";" 2> /dev/null

Here's what this does. It finds any file (in the current folder (.) and its subfolders) has an extension of (something) a r, thus .jar, or .aar (-name "*.?ar"). It outputs the archive's file name (-print). It then runs zipgrep (-exec). Zipgrep is told to search through any files in the archive ({}) named "AndroidManifest.xml", and output any line with the words "uses-permission". We then pipe the errors to the bit bucket (2> /dev/null) so we don't see lots of errors about archives that don't have android manifests in them.

An example output looks like this:

./OneSignal/Platforms/Android/onesignal-unity.aar AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> AndroidManifest.xml: <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> AndroidManifest.xml: <uses-permission android:name="android.permission.WAKE_LOCK" /> AndroidManifest.xml: <uses-permission android:name="android.permission.VIBRATE" /> ... ./Plugins/Android/android.arch.core.common-1.1.0.jar ./Plugins/Android/android.arch.core.runtime-1.1.0.aar ./Plugins/Android/android.arch.lifecycle.common-1.1.0.jar ... ./Plugins/Android/com.google.android.gms.play-services-gcm-11.8.0.aar AndroidManifest.xml: <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> ./Plugins/Android/com.google.android.gms.play-services-gcm-license-11.8.0.aar ./Plugins/Android/com.google.android.gms.play-services-iid-11.8.0.aar AndroidManifest.xml: <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" /> ./Plugins/Android/com.google.android.gms.play-services-iid-license-11.8.0.aar ...

The filenames all start with periods. I can thus see, for example, that the onesignal-unity.aar sets several permissions, several .jar files were searched with no permissions inside them, and some of the play services libraries specify permissions.

If I needed to change a library, I could rename the .aar to .zip, extract it, edit it, compress it, and rename it back. (It isn't necessarily wise to change the permissions inside a library, but possible.)

3. Unity Adds the Permission

I didn't have anything to add on this; as said above, if you use the Microphone API, Unity will add a permission for you so your app will work.

However, I've since realized that you can do the following:

  • bring up the Build Settings for Android
  • tick the 'Export Project' box
  • Export the project, noting the location
  • go to /my/project/export/src/main/AndroidManifest.xml. This is what Unity emits for the android manifest (before google's tools do all the merging).
  • compare it (using your favourite diff tool) to Assets/plugins/Android/AndroidManifest.xml; the differences come from Unity.

 

[출처]

https://stackoverflow.com/questions/40931058/how-to-find-source-of-a-permission-in-unity-android

 

How to find source of a permission in Unity Android

Note: This question is specific to Unity3D I have a very clean android manifest file in Unity project under Plugins/Android/ folder with no tag at all. I believe that some

stackoverflow.com

 

반응형
Posted by blueasa
, |

[링크]

https://mentum.tistory.com/150

 

유니티 퍼미션 체크 적용기. (Unity Permission Check)

2019.02.12 다른방식으로 포스트 재 작성 [주의] OBB를 사용하는 Split 빌드의 경우 반드시 저장소 권한을 획득해야함. [주의] 유니티 2018.3 부터 퍼미션체크가 내장되었습니다. 2018.3부터는 플러그인 필요없습..

mentum.tistory.com

 

반응형
Posted by blueasa
, |


[Free Asset] https://assetstore.unity.com/packages/tools/utilities/keystore-helper-58627


using UnityEngine;
using UnityEditor;
using System.IO;
 
[InitializeOnLoad]
public class PreloadSigningAlias
{
 
    static PreloadSigningAlias ()
    {
        PlayerSettings.Android.keystorePass = "KEYSTORE_PASS";
        PlayerSettings.Android.keyaliasName = "ALIAS_NAME";
        PlayerSettings.Android.keyaliasPass = "ALIAS_PASSWORD";
    }
 
}



[출처] https://forum.unity.com/threads/android-keystore-passwords-not-saved-between-sessions.235213/

반응형
Posted by blueasa
, |

안드로이드 유니티 리모트 4 연동 문제 해결하기

안드로이드에서 유니티 리모트를 연동하기 법은 구글형이 잘 알려준다. 여기서는 자주 발생하는 문제에 대한 해결책을 정리한다.
  1. 폰이 인식되지 않는다
  2. 인증되지 않았다
  3. 유니티에서 Play를 해도 반응이 없다

폰이 인식되지 않는다

일단 USB를 꽂으면, 인식이 되고, 탐색기로 봤을 때, 폰이 보이고, 폴더에 접근하여 파일을 복사하거나 삭제할 수 있어야 한다.

확인방법

  1. 탐색기에서 보이는지 확인
  2. adb로 확인
  3. 폰의 개발자 모드에서 USB 디버깅 활성화 체크

해결방법

  1. USB 통합 드라이브를 설치한다. (구글형에게 문의)
  2. 콘솔명령창에서 adb devices를 실행한다.
  3. 폰 설정에 들어가서 USB 디버깅을 활성화 한다. (구글형에게 문의)

폰이 인증되지 않았다

폰이 인식되면, USB 디버깅을 활성화하면, 유니티에서 Play를 할 때, 개발 컴퓨터의 접속을 허가할 지, 폰에서 묻는다. 이 때, 잘 응답하면 문제가 없으나, 잘못하면 인증이 안된 상태가 된다.

확인방법

  1. adb devices를 했을 때, 폰은 나오나 Unauthorized라고 나온다.

해결방법

콘솔 창에서 다음 명령을 실행한다
  1. adb kill-server
  2. adb start-server
위의 명령을 하고 다시 유니티에서 Play를 하면 폰에서 인증창이 다시 나온다.

유니티에서 Play를 해도 반응이 없다

유니티가 실행된 후에 폰을 연결한 경우, 유니티가 인식을 못하는 경우가 있다

확인방법

  1. 위의 문제의 확인 방법을 통해서 문제가 없는데도 Play를 하면 안된다

해결방법

  1. 유니티 에디터를 재실행한다


출처 : http://junhan627.blogspot.kr/2014/11/4.html

반응형
Posted by blueasa
, |

링크 1: http://forum.unity3d.com/threads/188441-Retrieving-MAC-address-on-Android-device


링크 2: http://stackoverflow.com/questions/6064510/how-to-get-ip-address-of-the-device/13007325#13007325

반응형
Posted by blueasa
, |

유니티를 안드로이드 버전으로 빌드하기 위해서 테스트를 해봤다.


내 폰은 아이폰이라 넣으면서 하진 못하고, 우선 apk 파일 만들기까지 해 봄..


아래는 안드로이드 빌드하기 위해 준비한 것 들.. 생각외로 간단하다..


1) 아래 링크로 가서 안드로이드 SDK를 설치한다.

    (http://developer.android.com/sdk/index.html)


2) JDK가 없으면 1) 설치 중에 JDK 설치하라고 뜬다. 아래 링크로 가서 Java SE를 받아서 설치해 주자..

    참고로 V7 버전이 빌드가 잘 안된다는 글이 있어서 V6으로 깔았다. 아래 링크에 두 버전 다 있음.. 선택..

    그리고, 윈도가 64bit(x64)라고 해서 64bit(x64)를 깔면 안됨.. 32bit(x86)로 깔라고 한다..

    (http://www.oracle.com/technetwork/java/javase/downloads/index.html)


3) 위 두 파일이 모두 설치되고 나면, 유니티의 'Edit-Preferences.-External Tools-Android SDK Location'으로 가서 폴더를 지정해 준다.(폴더 선택하러 들어가면 해당 폴더는 알아서 찾는 것 같다. 우측의 블럭된 폴더명을 삭제하고 그냥 '폴더 선택'을 누르면 된다.)


4) 'Android SDK Location' 셋팅을 하고 나서 'File-Build Settings-Platform'을 Android로 맞춘다.


5) 'File-Build Settings' 아래 Player 'Settings..' 를 누르면 Inspector 창에 이런저런 정보가 나오는데 아래와 같이 셋팅한다.

   (셋팅 설명은 있는데 정확히 무슨 옵션이고 뭘 위한건지 체크는 하지 못했다. 디폴트로 해보기도 해야될 것 같다.)

OtherSetting을 누르고

Identification 에서 Bundle Identifier 가 있는데 com.회사이름.플젝이름 이런식으로 고쳐서 써줌니다.

예) com.ABC.Project1

그리고 Minimum Api Level 에 현재 빌드할 폰의 안드로이드 버전에 맞게 설정합니다.

현재 폰의 버전보다 적은 버전해도 상관없음

Configuration 에서 Devices Level 을 ARMv6 with VFP 로 바꾸시고(Unity 4.x  버전에서는 ARMv7밖에 없으니 ARMv7로 하세요)

Graphics Level 을 OpenGL ES 1.x 로 바꿉니다.

그리고 Resolution and Presentation 을 누르고

Default Orientation 으로 어플의 뭐 가로세로 방향 을 고정시킬수있습니다.

Status Bar에 Status Bar Hidden은 핸드폰의 상단 바를 보이느냐 마느냐를 설정하는 것입니다.


6) 다하고나서 'File-Build Settings-Build' 를 하면 apk 파일이 생성된다.


7) 알아서 폰에 넣고 설치를..



참조 : http://cookzy.tistory.com/698

참조 : http://blog.naver.com/nameisljk/110136124090

반응형
Posted by blueasa
, |