Unity项目Android调试过程
本文目录 7 个章节
Unity项目Android调试过程
# Unity项目Android调试过程
创建时间:2020/8/21 14:24
- Unity Profiler的连接
- adb的一些技巧
- adb forward原理
- log获取
- 不太清楚为什么的操作
- 密码忘记
- Ref
- adb的一些技巧
Unity Profiler的连接
通过USB接口对安卓设备的程序进行分析:
Profiler中的选项:AndroidProfiler(ADB@127.0.0.1:34999)
The 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.
Required when Editor-to-Android connection is established via USB cableadb
class Program
{
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
//obj = obj + 3; 报错
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
}
Required when Android-to-Editor connection is established via USB cableadb
class Program
{
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
//obj = obj + 3; 报错
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
}
adb的一些技巧
adb forward原理
adb forward tcp:8888 tcp:9999 执行完该命令后,转发PC机8888端口的数据到手机的9999端口。
adb forward --list 查看一下转发是否成功,只有通过USB成功连接了手机该命令才能成功
log获取
log获取方法一:
class Program
{
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
//obj = obj + 3; 报错
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
}
log获取方法二(ddms调式):
android-sdk\tools 下的ddms.bat,运行。
点击+号添加Filter Name和by log cat
真机上启动刚刚Build的APK,就可以看见输出的Debug信息。
不太清楚为什么的操作
- 首先在手机上开启USB调试功能,并安装驱动。USB连接
- 确保手机和电脑在一个局域网内
adb连接
class Program
{
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
//obj = obj + 3; 报错
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
}
Run->Attach to process 会发现你手机的选项,选择手机,在脚本里面添加断点,你发现可以调试了
其他命令
class Program
{
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
//obj = obj + 3; 报错
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
}
密码忘记
adb shell cd data\system ls 如果设置了密码会有gesture.key或者password.key 若设置的是图案密码请继续输入命令:rm gesture.key 若设置的是单纯密码请输入命令:rm password.key reboot