{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/unity-android-debug-workflow/",
  "atlas": "https://www.pystone.net/?node=unity-android-debug-workflow#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/unity-android-debug-workflow.md",
  "context": "https://www.pystone.net/notes/unity-android-debug-workflow.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:unity-android-debug-workflow",
  "slug": "unity-android-debug-workflow",
  "title": "Unity项目Android调试过程",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "Unity项目Android调试过程",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "d75a46acb119e3d852c468dc9571657745ce157479e9eb0785fabad3e1d0fb18",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "Unity项目Android调试过程",
      "anchor": "unity项目android调试过程",
      "citation": "https://www.pystone.net/notes/unity-android-debug-workflow/#unity%E9%A1%B9%E7%9B%AEandroid%E8%B0%83%E8%AF%95%E8%BF%87%E7%A8%8B"
    },
    {
      "depth": 2,
      "text": "Unity Profiler的连接",
      "anchor": "unity-profiler的连接",
      "citation": "https://www.pystone.net/notes/unity-android-debug-workflow/#unity-profiler%E7%9A%84%E8%BF%9E%E6%8E%A5"
    },
    {
      "depth": 2,
      "text": "adb的一些技巧",
      "anchor": "adb的一些技巧",
      "citation": "https://www.pystone.net/notes/unity-android-debug-workflow/#adb%E7%9A%84%E4%B8%80%E4%BA%9B%E6%8A%80%E5%B7%A7"
    },
    {
      "depth": 3,
      "text": "adb forward原理",
      "anchor": "adb-forward原理",
      "citation": "https://www.pystone.net/notes/unity-android-debug-workflow/#adb-forward%E5%8E%9F%E7%90%86"
    },
    {
      "depth": 3,
      "text": "log获取",
      "anchor": "log获取",
      "citation": "https://www.pystone.net/notes/unity-android-debug-workflow/#log%E8%8E%B7%E5%8F%96"
    },
    {
      "depth": 3,
      "text": "不太清楚为什么的操作",
      "anchor": "不太清楚为什么的操作",
      "citation": "https://www.pystone.net/notes/unity-android-debug-workflow/#%E4%B8%8D%E5%A4%AA%E6%B8%85%E6%A5%9A%E4%B8%BA%E4%BB%80%E4%B9%88%E7%9A%84%E6%93%8D%E4%BD%9C"
    },
    {
      "depth": 3,
      "text": "密码忘记",
      "anchor": "密码忘记",
      "citation": "https://www.pystone.net/notes/unity-android-debug-workflow/#%E5%AF%86%E7%A0%81%E5%BF%98%E8%AE%B0"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/unity-android-debug-workflow/#ref"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "Unity中的“Unity项目Android调试过程”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#unity"
    }
  ],
  "contentMarkdown": "# Unity项目Android调试过程\n\n﻿# Unity项目Android调试过程\n\n> 创建时间：2020/8/21 14:24\n\n* Unity Profiler的连接\n  * adb的一些技巧\n    * adb forward原理\n    * log获取\n    * 不太清楚为什么的操作\n    * 密码忘记\n  * Ref\n\n## Unity Profiler的连接\n\n通过USB接口对安卓设备的程序进行分析：\n\nProfiler中的选项：AndroidProfiler(ADB@127.0.0.1:34999)\n\nThe Unity Editor automatically creates an adb **tunnel** for your application when you select **Build & Run**. If you want to **profile another application** , or you **restart the adb server** , you need to configure this tunnel manually.\n\nRequired when Editor-to-Android connection is established via USB cableadb\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\nRequired when Android-to-Editor connection is established via USB cableadb\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\n## adb的一些技巧\n\n### adb forward原理\n\nadb forward tcp:8888 tcp:9999\n执行完该命令后，转发PC机8888端口的数据到手机的9999端口。\n\nadb forward --list\n查看一下转发是否成功，只有通过USB成功连接了手机该命令才能成功\n\n### log获取\n\nlog获取方法一：\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\nlog获取方法二（ddms调式）：\n\nandroid-sdk\\tools 下的ddms.bat，运行。\n\n点击+号添加Filter Name和by log cat\n\n真机上启动刚刚Build的APK，就可以看见输出的Debug信息。\n\n### 不太清楚为什么的操作\n\n  1. 首先在手机上开启USB调试功能，并安装驱动。USB连接\n  2. 确保手机和电脑在一个局域网内\n\nadb连接\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\nRun->Attach to process 会发现你手机的选项，选择手机，在脚本里面添加断点，你发现可以调试了\n\n其他命令\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\n### 密码忘记\n\nadb shell\ncd data\\system\nls\n如果设置了密码会有gesture.key或者password.key\n若设置的是图案密码请继续输入命令：rm gesture.key\n若设置的是单纯密码请输入命令：rm password.key\nreboot\n\n## Ref\n\nhttps://gameinstitute.qq.com/community/detail/124474\n"
}
