[Android] Connect Unity Profiler to Mobile Device

#유니티 프로파일러를 모바일 디바이스에 연결하기

There is a good descrption about how to remote profiling on device on Unity Manual page (Link). However, sometimes it doesn’t work like that if you miss some parts or mix the procedure.  This is easy steps you can follow.

  • Build with option check ‘Development Build’ on Build Settings. (빌드 세팅에서 Development Build 체크해서 빌드하기)
  • Install the app just built. (디바이스에 앱 설치)
  • Check the cable connection between PC/Mac and the device. (케이블이 컴퓨터와 디바이스사이에 잘 연결되어 있는지 확인)
  • Open any command console on PC/Mac (커맨드창 열기)
  • Check if the device is detected through adb command. (아래 명령어를 쳐서 디바이스 인식 확인)
    • > adb devices
if any device is not attached, you should check if the device driver is installed properly.
  • Open adb tunnel between Unity Editor and the installed app (유니티 에디터와 앱 사이에 adb 터널링 만들기)
    • > adb forward tcp:34999 localabstract:Unity-{insert bundle identifier here}
    • if unity version is under Unity 5.x, then port number is 54999. (5.x 버전일 경우 포트 54999)
  • Start Unity editor. (Don’t start Unity editor before adb tunneling) (유니티 에디터 시작. adb 터널링 전에 유니티 에디터를 먼저 시작하지 말것)
  • Open Profiler window ( Unity top menu: Window > Profiler ) (프로파일러 윈도우 열기)
  • Select the AndroidProfiler(ADB@127.0.0.1:34999) on Active Profiler dropdown menu (Active Profiler 드롭다운 메뉴에서 AndroidProfiler 선택)
Profiler dropdown menu
  • You should see cpu, memory, and various graphs from there. (그래프들이 표시되면서 프로파일링이 잘 되는지 확인)

  • If not showing any graph, or if active profiler is not AndroidProfiler(ADB@127.0.0.1:34999), then follow below steps. (만약 그래프가 안보이거나 AndroidProfiler가 선택이 안되다면,)
  • Stop/close Unity editor process completely. (RESTART STEP) (유니티 에디터 종료)
  • Restart adb server (adb 서버 재시작)
    • > adb kill-server
    • > adb start-server
  • Open adb tunnel again. (다시 adb 터널링)
    • > adb forward tcp:34999 localabstract:Unity-{insert bundle identifier here}
  • Start Unity editor. (유니티 에디터 시작)
  • Open Profiler window. (프로파일러 윈도우 열기)
  • Select the AndroidProfiler(ADB@127.0.0.1:34999) on Active Profiler dropdown menu. (Active Profiler에서 AndroidProfiler 선택)
  • You should see various graphs now. (프로파일링 되는지 확인)
  • You might disconnect the tunnel if you unplug your device from PC/Mac. Then follow steps from “RESTART STEP” again. (디바이스를 컴퓨터에서 뽑았을때 터널링이 끊겼을 수 있으므로 RESTART STEP으로 부터 다시 세팅)

  • If you are still not seeing any profiling results, then check firewall port settings. (그래도 안되면, 방화벽 포트 세팅 확인)
    • (Windows) Control panels > System and security > Windows firewall > Advanced settings
      • Click Outbound Rules
      • Click New Rule… on Actions
      • Port
        • TCP / 54998-55511
      • Set any name such as UnityRemoteProfiling.
  • Then follow steps from “RESTART STEP” again.

Leave a Reply

Your email address will not be published. Required fields are marked *