scrcpy安装使用

scrcpy 支持键盘输入,连接设备稳定,操作虚拟机或连接手机流畅。本章内容适合已安装好android-skd创建好虚拟机emulator的前提下阅读,当然scrcpy也适合你直接用abd连接你的手机进行投屏。

安装scrcpy

点击这里

点击下载或者使用wget下载(自己去搜国内github代理)

1
wget https://github.com/Genymobile/scrcpy/releases/download/v3.2/scrcpy-linux-x86_64-v3.2.tar.gz

下载完后解压

1
2
tar -zxvf scrcpy-linux-x86_64-v3.2.tar.gz 
sudo mv scrcpy-linux-x86_64-v3.2 /opt/scrcpy

创建ubuntu快捷图标

1
vim ~/Desktop/scrcpy.desktop

粘贴以下内容

1
2
3
4
5
6
7
8
9
#!/bin/bash
[Desktop Entry]
Version=1.0
Type=Application
Name=Scrcpy
Icon=/opt/scrcpy/icon.png
Exec=/opt/scrcpy/scrcpy
Comment=scrcpy
Terminal=false

赋予可执行权限

1
sudo chmod u+x ~/Desktop/scrcpy.desktop

无窗口启动android虚拟机

1
emulator -avd test -no-wind

重启adb服务

1
2
adb kill-server
adb start-server

双击桌面上的scrcpy

android虚拟机创建参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
avdmanager create avd -n test -k "system-images;android-Baklava;google_apis_playstore;x86_64"
使用 avdmanager 创建一个名为“test”的 Android 虚拟设备(AVD),并指定使用“system-images;android-Baklava;google_apis_playstore;x86_64”系统镜像

[=======================================] 100% Fetch remote repository...
[进度条显示] 100% 正在获取远程仓库...

Auto-selecting single ABI x86_64
自动选择单个应用二进制接口(ABI):x86_64

Do you wish to create a custom hardware profile? [no] yes
你是否希望创建一个自定义的硬件配置文件?[否] 是

0: PlayStore: Does the device supports Google Play?
0:Google Play 商店:该设备是否支持 Google Play 商店?
PlayStore.enabled [no]:yes
是否启用 Google Play 商店 [否]:是

1: avd home that was used during the construction of this hardware.ini: This can be used by post processing tools to migrate snapshots
1:在构建此硬件配置文件(hardware.ini)期间使用的 AVD 主目录:这可被后期处理工具用于迁移快照
android.avd.home []:

2: sdk root that was used during the construction of this hardware.ini: This can be used by post processing tools to migrate snapshots
2:在构建此硬件配置文件(hardware.ini)期间使用的 SDK 根目录:这可被后期处理工具用于迁移快照
android.sdk.root []:

3: ID of the AVD being run:
3:正在运行的 AVD 的 ID:
avd.id [<build>]:test
AVD 的 ID [<build>]:test

4: Name of the AVD being run:
4:正在运行的 AVD 的名称:
avd.name [<build>]:test
AVD 的名称 [<build>]:test

5: Cache partition support: Whether we use a /cache partition on the device.
5:缓存分区支持:我们是否在设备上使用 /cache 分区。
disk.cachePartition [yes]:

6: Cache partition: Cache partition to use on the device. Ignored if disk.cachePartition is not 'yes'.
6:缓存分区:在设备上使用的缓存分区。如果 disk.cachePartition 的值不是“是”,则此设置将被忽略。
disk.cachePartition.path []:

7: Cache partition size:
7:缓存分区大小:
disk.cachePartition.size [66MB]:

8: Initial data partition: If not empty, its content will be copied to the disk.dataPartition.path file at boot-time.
8:初始数据分区:如果不为空,其内容将在启动时复制到 disk.dataPartition.path 文件中。
disk.dataPartition.initPath []:

9: Path to data partition file: Path to data partition file. Cannot be empty. Special value <temp> means using a temporary file. If disk.dataPartition.initPath is not empty, its content will be copied to the disk.dataPartition.path file at boot-time.
9:数据分区文件路径:数据分区文件的路径。不能为空。特殊值 <temp> 表示使用临时文件。如果 disk.dataPartition.initPath 不为空,其内容将在启动时复制到 disk.dataPartition.path 文件中。
disk.dataPartition.path [<temp>]:

10: Ideal size of data partition:
10:数据分区的理想大小:
disk.dataPartition.size [0]:

11: Path to encryption key partition file: Path to encryption key partition file. Should be at least 16K bytes empty disk without any filesystem on it.
11:加密密钥分区文件路径:加密密钥分区文件的路径。该磁盘至少应有 16K 字节的可用空间且没有任何文件系统。
disk.encryptionKeyPartition.path []:

12: Path to the ramdisk image: Path to the ramdisk image.
12:内存盘镜像路径:内存盘镜像的路径。
disk.ramdisk.path []:

13: Path to snapshot storage: Path to a 'snapshot storage' file, where all snapshots are stored.
13:快照存储路径:一个“快照存储”文件的路径,所有快照都将存储在该文件中。
disk.snapStorage.path []:

14: Initial system partition image:
14:初始系统分区镜像:
disk.systemPartition.initPath []:

15: Path to runtime system partition image:
15:运行时系统分区镜像路径:
disk.systemPartition.path []:

16: Ideal size of system partition:
16:系统分区的理想大小:
disk.systemPartition.size [0]:

17: Initial vendor partition image:
17:初始供应商分区镜像:
disk.vendorPartition.initPath []:

18: Path to runtime vendor partition image:
18:运行时供应商分区镜像路径:
disk.vendorPartition.path []:

19: Ideal size of vendor partition:
19:供应商分区的理想大小:
disk.vendorPartition.size [0]:

20: Configure setting xml file for Android Window Manager:
20:为 Android 窗口管理器配置设置 XML 文件:
display.settings.xml []:

21: Always use cold boot: If set, AVD will always use the full cold boot instead of snapshot-based quick boot process
21:始终使用冷启动:如果设置为“是”,AVD 将始终使用完全冷启动,而不是基于快照的快速启动过程
fastboot.forceColdBoot [no]:

22: Always use downloaded snapshot to speed up first boot: If set, AVD will always use the snapshots/downloaded/avd to speed up first boot
22:始终使用下载的快照来加快首次启动速度:如果设置为“是”,AVD 将始终使用 snapshots/downloaded/avd 中的快照来加快首次启动速度
firstboot.bootFromDownloadableSnapshot [yes]:

23: Always use local snapshot to speed up first boot: If set, AVD will always use the snapshots/local/avd to speed up first boot
23:始终使用本地快照来加快首次启动速度:如果设置为“是”,AVD 将始终使用 snapshots/local/avd 中的快照来加快首次启动速度
firstboot.bootFromLocalSnapshot [yes]:

24: Path to downloaded snapshot dir:
24:下载的快照目录路径:
firstboot.downloaded.path []:

25: Path to local snapshot dir:
25:本地快照目录路径:
firstboot.local.path []:

26: Always save a local snapshot to speed up first boot: If set, AVD will save a snapshot to snapshots/local/avd, if it does not exist
26:始终保存本地快照以加快首次启动速度:如果设置为“是”,如果 snapshots/local/avd 中不存在快照,AVD 将保存一个快照到该目录中
firstboot.saveToLocalSnapshot [yes]:

27: Accelerometer: Whether there is an accelerometer in the device.
27:加速度计:设备中是否有加速度计。
hw.accelerometer [yes]:

28: AccelerometerUncalibrated: Whether there is an uncalibrated accelerometer in the device.
28:未校准的加速度计:设备中是否有未校准的加速度计。
hw.accelerometer_uncalibrated [yes]:

29: Chrome OS device (App Runtime for Chrome): The emulated device is a Chrome OS machine.
29:Chrome OS 设备(Chrome 应用运行时):模拟的设备是一台 Chrome OS 机器。
hw.arc [no]:

30: Auto login for Chrome OS devices: Used to enable auto login into Chrome OS devices
30:Chrome OS 设备自动登录:用于启用 Chrome OS 设备的自动登录功能
hw.arc.autologin [no]:

31: Audio recording support: Whether the device can record audio
31:音频录制支持:设备是否可以录制音频
hw.audioInput [yes]:

32: Audio playback support: Whether the device can play audio
32:音频播放支持:设备是否可以播放音频
hw.audioOutput [yes]:

33: Battery support: Whether the device can run on a battery.
33:电池支持:设备是否可以使用电池运行。
hw.battery [yes]:

34: Configures camera facing back: Must be 'emulated' for a fake camera, 'webcam<N>' for a web camera, or 'none' if back camera is disabled.
34:配置后置摄像头:如果是虚拟摄像头必须设置为“emulated”,如果是网络摄像头则为“webcam<N>”,如果禁用后置摄像头则为“none”。
hw.camera.back [emulated]:

35: Configures camera facing front: Must be 'emulated' for a fake camera, 'webcam<N>' for a web camera, or 'none' if front camera is disabled.
35:配置前置摄像头:如果是虚拟摄像头必须设置为“emulated”,如果是网络摄像头则为“webcam<N>”,如果禁用前置摄像头则为“none”。
hw.camera.front [none]:

36: CPU Architecture: The CPU Architecture to emulator
36:CPU 架构:要模拟的 CPU 架构
hw.cpu.arch [arm]:

37: CPU model: The CPU model (QEMU-specific string)
37:CPU 型号:CPU 型号(特定于 QEMU 的字符串)
hw.cpu.model []:

38: SMP CPU core count: Number of cores in a simulated SMP CPU.
38:对称多处理(SMP)CPU 核心数:模拟的 SMP CPU 中的核心数量。
hw.cpu.ncore [2]:

39: DPad support: Whether the device has DPad keys
39:方向键(DPad)支持:设备是否有方向键
hw.dPad [yes]:

40: Name of the device, e.g., pixel, resizable...# Kernel image.:
40:设备名称,例如,像素(pixel),可调整大小(resizable)...# 内核镜像:
hw.device.name []:

41: Screen density of the second display:
41:第二个显示屏的屏幕密度:
hw.display1.density [0]:

42: the flag to use when the second display is initialized in the Android system.:
42:在 Android 系统中初始化第二个显示屏时使用的标志:
hw.display1.flag [0]:

43: Pixel height of the second display:
43:第二个显示屏的像素高度:
hw.display1.height [0]:

44: Pixel width of the second display:
44:第二个显示屏的像素宽度:
hw.display1.width [0]:

45: the horizontal offset of the second display with respect to the host QT window.:
45:第二个显示屏相对于主机 QT 窗口的水平偏移量:
hw.display1.xOffset [-1]:

46: the veritcal offset of the second display with respect to the host QT window.:
46:第二个显示屏相对于主机 QT 窗口的垂直偏移量:
hw.display1.yOffset [-1]:

47: Screen density of the third display:
47:第三个显示屏的屏幕密度:
hw.display2.density [0]:

48: the flag to use when the third display is initialized in the Android system.:
48:在 Android 系统中初始化第三个显示屏时使用的标志:
hw.display2.flag [0]:

49: Pixel height of the third display:
49:第三个显示屏的像素高度:
hw.display2.height [0]:

50: Pixel width of the third display:
50:第三个显示屏的像素宽度:
hw.display2.width [0]:

51: the horizontal offset of the third display with respect to the host QT window.:
51:第三个显示屏相对于主机 QT 窗口的水平偏移量:
hw.display2.xOffset [-1]:

52: the veritcal offset of the third display with respect to the host QT window.:
52:第三个显示屏相对于主机 QT 窗口的垂直偏移量:
hw.display2.yOffset [-1]:

53: Screen density of the fourth display:
53:第四个显示屏的屏幕密度:
hw.display3.density [0]:

54: the flag touse when the fourth display is initialized in the Android system.:
54:在 Android 系统中初始化第四个显示屏时使用的标志:
hw.display3.flag [0]:

55: Pixel height of the fourth display:
55:第四个显示屏的像素高度:
hw.display3.height [0]:

56: Pixel width of the fourth display:
56:第四个显示屏的像素宽度:
hw.display3.width [0]:

57: the horizontal offset of the fourth display with respect to the host QT window.:
57:第四个显示屏相对于主机 QT 窗口的水平偏移量:
hw.display3.xOffset [-1]:

58: the veritcal offset of the fourth display with respect to the host QT window.:
58:第四个显示屏相对于主机 QT 窗口的垂直偏移量:
hw.display3.yOffset [-1]:

59: Vertical size of the sub-region:
59:子区域的垂直大小:
hw.displayRegion.0.1.height [0]:

60: Horizontal size of the sub-region:
60:子区域的水平大小:
hw.displayRegion.0.1.width [0]:

61: Horizontal offset of the sub-region:
61:子区域的水平偏移量:
hw.displayRegion.0.1.xOffset [-1]:

62: Vertical offset of the sub-region:
62:子区域的垂直偏移量:
hw.displayRegion.0.1.yOffset [-1]:

63: Vertical size of the sub-region:
63:子区域的垂直大小:
hw.displayRegion.0.2.height [0]:

64: Horizontal size of the sub-region:
64:子区域的水平大小:
hw.displayRegion.0.2.width [0]:

65: Horizontal offset of the sub-region:
65:子区域的水平偏移量:
hw.displayRegion.0.2.xOffset [-1]:

66: Vertical offset of the sub-region:
66:子区域的垂直偏移量:
hw.displayRegion.0.2.yOffset [-1]:

67: Vertical size of the sub-region:
67:子区域的垂直大小:
hw.displayRegion.0.3.height [0]:

68: Horizontal size of the sub-region:
68:子区域的水平大小:
hw.displayRegion.0.3.width [0]:

69: Horizontal offset of the sub-region:
69:子区域的水平偏移量:
hw.displayRegion.0.3.xOffset [-1]:

70: Vertical offset of the sub-region:
70:子区域的垂直偏移量:
hw.displayRegion.0.3.yOffset [-1]:

71: Feature flags: A comma-separated list of feature flags to enable or disable, such as 'Enabled,-Disabled'.
71:功能标志:一个以逗号分隔的功能标志列表,用于启用或禁用功能,例如“Enabled,-Disabled”。
hw.featureflags []:

72: Transport used to run graphics:
72:用于运行图形的传输方式:
hw.gltransport [pipe]:

73: For address space graphics, the size of the ring used to transfer larger buffers.:
73:对于地址空间图形,用于传输较大缓冲区的环形缓冲区大小:
hw.gltransport.asg.dataRingSize [32768]:

74: For address space graphics, the total size of the write buffer the guest can write into:
74:对于地址空间图形,客户机可以写入的写入缓冲区的总大小:
hw.gltransport.asg.writeBufferSize [1048576]:

75: For address space graphics, the max size of each guest-to-host transaction.:
75:对于地址空间图形,每个从客户机到主机事务的最大大小:
hw.gltransport.asg.writeStepSize [4096]:

76: Interval over which to flush draw calls (balance host gpu starve vs pipe notif overhead):
76:刷新绘图调用的时间间隔(平衡主机 GPU 饥饿与管道通知开销):
hw.gltransport.drawFlushInterval [800]:

77: GPS support: Whether there is a GPS in the device.
77:全球定位系统(GPS)支持:设备中是否有 GPS。
hw.gps [yes]:

78: GPU emulation: Enable/Disable emulated OpenGLES GPU
78:GPU 模拟:启用/禁用模拟的 OpenGLES GPU
hw.gpu.enabled [no]:

79: GPU emulation mode: This value determines how GPU emulation is implemented.
79:GPU 模拟模式:此值决定 GPU 模拟的实现方式。
hw.gpu.mode [auto]:

80: GSM modem support: Whether there is a GSM modem in the device.
80:全球移动通信系统(GSM)调制解调器支持:设备中是否有 GSM 调制解调器。
hw.gsmModem [yes]:

81: Gyroscope: Whether there is a gyroscope in the device.
81:陀螺仪:设备中是否有陀螺仪。
hw.gyroscope [yes]:

82: If yes, create multidisplay using HAL hotplug display, otherwise, using Android window manager:
82:如果设置为“是”,使用 HAL 热插拔显示屏创建多显示屏,否则,使用 Android 窗口管理器:
hw.hotplug_multi_display [no]:

83: Initial screen orientation: Setup initial screen orientation, can be rotated later on.
83:初始屏幕方向:设置初始屏幕方向,之后可以旋转。
hw.initialOrientation [portrait]:

84: Keyboard support: Whether the device has a QWERTY keyboard.
84:键盘支持:设备是否有 QWERTY 键盘。
hw.keyboard [no]:

85: Keyboard charmap name: Name of the system keyboard charmap file.
85:键盘字符映射表名称:系统键盘字符映射表文件的名称。
hw.keyboard.charmap [qwerty2]:
86: Keyboard lid support: Whether the QWERTY keyboard can be opened/closed.
86:键盘盖支持:QWERTY 键盘是否可以打开 / 关闭。
hw.keyboard.lid [yes]:
87: LCD backlight: Enable/Disable LCD backlight simulation,yes-enabled,no-disabled.
87:液晶显示屏(LCD)背光灯:启用 / 禁用 LCD 背光灯模拟,“是” 表示启用,“否” 表示禁用。
hw.lcd.backlight [yes]:
88: Display is circular: Specifies if the main display is circular (round). Default: false.
88:显示屏为圆形:指定主显示屏是否为圆形(圆形)。默认值:否。
hw.lcd.circular [false]:
89: Abstracted LCD density: A value used to roughly describe the density of the LCD screen for automatic resource/asset selection.
89:抽象的 LCD 密度:一个用于大致描述 LCD 屏幕密度的值,以便自动选择资源 / 资产。
hw.lcd.density [160]:
90: LCD color depth: Color bit depth of emulated framebuffer.
90:LCD 颜色深度:模拟帧缓冲区的颜色位深度。
hw.lcd.depth [16]:
91: LCD pixel height:
91:LCD 像素高度:
hw.lcd.height [640]:
92: LCD VSYNC rate:
92:LCD 垂直同步速率:
hw.lcd.vsync [60]:
93: LCD pixel width:
93:LCD 像素宽度:
hw.lcd.width [320]:
94: Logcat Output File Path:
94:日志猫(Logcat)输出文件路径:
hw.logcatOutput.path []:
95: Hardware Back/Home keys: Whether there are hardware back/home keys on the device.
95:硬件返回 / 主页键:设备上是否有硬件返回 / 主页键。
hw.mainKeys [yes]:
96: Create a window for each display: When multidisplay enabled, enabling this flag will create a window for each display.
96:为每个显示屏创建一个窗口:当启用多显示屏功能时,启用此标志将为每个显示屏创建一个窗口。
hw.multi_display_window [no]:
97: Device ram size: The amount of physical RAM on the device, in megabytes.
97:设备内存大小:设备上的物理内存容量,单位为兆字节。
hw.ramSize [0]:
98: : A comma-separated list of resizable resolutions. Each entry is organized as name-id-width-height-dpi, where the id number matches enum in android/android-emu/android/resizable_display_config.h
98:可调整大小的分辨率的逗号分隔列表。每个条目按名称 - 标识 - 宽度 - 高度 - 每英寸点数(dpi)的格式组织,其中标识号与 android/android-emu/android/resizable_display_config.h 中的枚举匹配。
hw.resizable.configs []:
99: Rotary input support: Whether the device has rotary input
99:旋转输入支持:设备是否具有旋转输入功能
hw.rotaryInput [no]:
100: Touch screen type: Defines type of the screen.
100:触摸屏类型:定义屏幕的类型。
hw.screen [multi-touch]:
101: SD Card support: Whether the device supports insertion/removal of virtual SD Cards.
101:SD 卡支持:设备是否支持插入 / 移除虚拟 SD 卡。
hw.sdCard [yes]:
102: SD Card image path:
102:SD 卡镜像路径:
hw.sdCard.path []:
103: Enalbe hinge angle sensor.:
103:启用铰链角度传感器。
hw.sensor.hinge [no]:
104: hinge areas on the display, format is percentage_of_screen-width, e.g., 33.3-0, 66.6-10 for two sensors. Or x-y-width-height, e.g., 600-0-0-1200, 1200-0-10-1200 for two sensors.:
104:显示屏上的铰链区域,格式为屏幕宽度的百分比,例如,对于两个传感器为 33.3-0,66.6-10。或者 x-y - 宽度 - 高度,例如,对于两个传感器为 600-0-0-1200,1200-0-10-1200。
hw.sensor.hinge.areas []:
105: Provides hinge angle sensor count.:
105:提供铰链角度传感器的数量。
hw.sensor.hinge.count [0]:
106: default angel for each hinge sensor, e.g., 180, 90 for two sensors.:
106:每个铰链传感器的默认角度,例如,对于两个传感器为 180,90。
hw.sensor.hinge.defaults []:
107: set folded status at a certain posture, e.g, fold-out device, posture flipped:
107:在特定姿势下设置折叠状态,例如,展开设备,翻转姿势:
hw.sensor.hinge.fold_to_displayRegion.0.1_at_posture [1]:
108: angel ranges for each hinge sensor, e.g., 0-360, 0-180 for two sensors.:
108:每个铰链传感器的角度范围,例如,对于两个传感器为 0-360,0-180。
hw.sensor.hinge.ranges []:
109: For resizable only: this indicates the hinge config applies to which avd:
109:仅适用于可调整大小的情况:这表示铰链配置适用于哪个 AVD:
hw.sensor.hinge.resizable.config [1]:
110: Provides hinge angle sensor sub type. 0 (invisible hinge, fold on screen) and 1 (hinge):
110:提供铰链角度传感器子类型。0(不可见铰链,在屏幕上折叠)和 1(铰链):
hw.sensor.hinge.sub_type [0]:
111: Provides hinge angle sensor type. 0 (horizontal) and 1 (vertical):
111:提供铰链角度传感器类型。0(水平)和 1(垂直):
hw.sensor.hinge.type [0]:
112: angles ranges for each posture in posture_list.: start-end angle pairs which define each posture. optionally, default angle may be specified for each posture, by providing a third value. default posture angle is used e.g. in quick-jump-to-posture buttons in UI.
112:姿势列表中每个姿势的角度范围:定义每个姿势的起始 - 结束角度对。可选地,可以通过提供第三个值为每个姿势指定默认角度。默认姿势角度例如在用户界面的快速跳转到姿势按钮中使用。
hw.sensor.hinge_angles_posture_definitions []:
113: list of supported postures by index. 0: unknown, 1: closed, 2: half-open, 3: open, 4: flipped, 5: tent:
113:按索引列出的支持姿势。0:未知,1:关闭,2:半开,3:打开,4:翻转,5:帐篷状:
hw.sensor.posture_list []:
114: Enalbe rollable sensor.:
114:启用可滚动传感器。
hw.sensor.roll [no]:
115: rollable sensor count.:
115:可滚动传感器的数量。
hw.sensor.roll.count [0]:
116: defaults percentage of display width or height which is rolled.:
116:滚动的显示屏宽度或高度的默认百分比。
hw.sensor.roll.defaults []:
117: rolling direction starting from open posture. 0: left-to-right or top-to-buttom, 1: right-to-left or bottom-to-top:
117:从打开姿势开始的滚动方向。0:从左到右或从上到下,1:从右到左或从下到上:
hw.sensor.roll.direction []:
118: roll radious of display width or height.:
118:显示屏宽度或高度的滚动半径。
hw.sensor.roll.radius []:
119: the pecentage of display width or height which is rollable.:
119:可滚动的显示屏宽度或高度的百分比。
hw.sensor.roll.ranges []:
120: resize default display to display region 0.1 when rolling to a posture state:
120:当滚动到某个姿势状态时,将默认显示屏调整为显示区域 0.1 的大小:
hw.sensor.roll.resize_to_displayRegion.0.1_at_posture [6]:
121: resize default display to display region 0.2 when rolling to a posture state:
121:当滚动到某个姿势状态时,将默认显示屏调整为显示区域 0.2 的大小:
hw.sensor.roll.resize_to_displayRegion.0.2_at_posture [6]:
122: resize default display to display region 0.3 when rolling to a posture state:
122:当滚动到某个姿势状态时,将默认显示屏调整为显示区域 0.3 的大小:
hw.sensor.roll.resize_to_displayRegion.0.3_at_posture [6]:
123: angles ranges for each posture in posture_list.:
123:姿势列表中每个姿势的角度范围:
hw.sensor.roll_percentages_posture_definitions []:
124: Uncalibrated gyroscope support: Provides uncalibrated gyroscope sensor values.
124:未校准陀螺仪支持:提供未校准的陀螺仪传感器值。
hw.sensors.gyroscope_uncalibrated [yes]:
125: Heart rate support: Whether there is a heart rate sensor in the device
125:心率支持:设备中是否有心率传感器
hw.sensors.heart_rate [no]:
126: Humidity support: Whether there is a relative humidity sensor in the device
126:湿度支持:设备中是否有相对湿度传感器
hw.sensors.humidity [yes]:
127: Light support: Whether there is a light sensor in the device
127:光线支持:设备中是否有光线传感器
hw.sensors.light [yes]:
128: Magnetic field support: Provides magnetic field sensor values.
128:磁场支持:提供磁场传感器值。
hw.sensors.magnetic_field [yes]:
129: Uncalibrated magnetic field suport: Provides uncalibrated magnetic field sensor values.
129:未校准磁场支持:提供未校准的磁场传感器值。
hw.sensors.magnetic_field_uncalibrated [yes]:
130: Orientation support: Provides orientation sensor values.
130:方向支持:提供方向传感器值。
hw.sensors.orientation [yes]:
131: Pressure support: Whether there is a pressure sensor in the device
131:压力支持:设备中是否有压力传感器
hw.sensors.pressure [yes]:
132: Proximity support: Whether there is an proximity in the device.
132:接近度支持:设备中是否有接近传感器。
hw.sensors.proximity [yes]:
133: RGBC light sensor support: Provides RGBC light sensor values.
133:RGBC 光线传感器支持:提供 RGBC 光线传感器值。
hw.sensors.rgbclight [no]:
134: Temperature support: Provides temperature sensor values.
134:温度支持:提供温度传感器值。
hw.sensors.temperature [yes]:
135: Wrist tilt gesture: Whether there is a wrist tilt gesture sensor in the device
135:手腕倾斜手势:设备中是否有手腕倾斜手势传感器
hw.sensors.wrist_tilt [no]:
136: Track-ball support: Whether there is a trackball on the device.
136:轨迹球支持:设备上是否有轨迹球。
hw.trackBall [yes]:
137: Deprecated option. Ignored.: Used to specify the Ext4 partition image type. This is now autodetected.
137:已弃用的选项。将被忽略。:用于指定 Ext4 分区镜像类型。现在此选项会自动检测。
hw.useext4 [yes]:
138: Does the kernel require a new device naming scheme?: Used to specify whether the kernel requires a new device naming scheme. Typically for Linux 3.10 and above.
138:内核是否需要新的设备命名方案?:用于指定内核是否需要新的设备命名方案。通常适用于 Linux 3.10 及以上版本。
kernel.newDeviceNaming [autodetect]:
139: kernel boot parameters string.:
139:内核启动参数字符串:
kernel.parameters []:
140: Path to the kernel image: Path to the kernel image.
140:内核镜像路径:内核镜像的路径。
kernel.path []:
141: Does the kernel supports YAFFS2 partitions?: Used to specify whether the kernel supports YAFFS2 partition images. Typically before 3.10 only.
141:内核是否支持 YAFFS2 分区?:用于指定内核是否支持 YAFFS2 分区镜像。通常仅适用于 3.10 版本之前的内核。
kernel.supportsYaffs2 [autodetect]:
142: avd requires the version of emulator to boot properly from snapshot: This is often set by avd manager in studio when creating avd
142:AVD 需要特定版本的模拟器才能从快照正确启动:这通常在创建 AVD 时由开发环境(如 Android Studio)中的 AVD 管理器设置
requires.emulator.version []:
143: Delay sending data to guest adb until guest completed booting:
143:在客户机(模拟器)完成启动之前,延迟向客户机的 ADB(安卓调试桥)发送数据:
test.delayAdbTillBootComplete [0]:
144: Monitor Adb messages between guest and host. Default: Disabled.:
144:监控客户机和主机之间的 ADB 消息。默认值:禁用。
test.monitorAdb [0]:
145: Quit emulator after guest boots completely, or after time out. Default: end of universe.:
145:在客户机完全启动后或超时后退出模拟器。默认值:无期限(永远不退出)。
test.quitAfterBootTimeOut [-1]:
146: use QCOW2 format for userdata-qemu.img: If set, AVD will use qcow2 for userdata-qemu.img instead of the ext4
146:对 userdata-qemu.img 使用 QCOW2 格式:如果设置为 “是”,AVD 将对 userdata-qemu.img 使用 qcow2 格式而不是 ext4 格式
userdata.useQcow2 [no]:
147: Max VM application heap size: The maximum heap size a Dalvik application might allocate before being killed by the system. Value is in megabytes.
147:最大虚拟机应用堆大小:在被系统终止之前,Dalvik 应用可能分配的最大堆大小。单位为兆字节。
vm.heapSize [0]:

github仓库操作

列出仓库
1
gh repo list <用户名>

添加仓库

公开仓库

例如,创建一个名为 new-public-repo 的公开仓库,命令如下:

1
gh repo create new-public-repo --public
私有仓库

例如,创建一个名为 new-private-repo 的私有仓库,命令如下:

1
gh repo create new-private-repo --private
带有描述的仓库

如果你想在创建仓库时添加描述信息,可以使用 --description 参数。示例如下,创建一个名为 new-desc-repo 且带有描述信息的公开仓库:

bash

1
gh repo create new-desc-repo --public --description "这是一个带有描述的新仓库"

删除仓库

1
gh repo delete <用户名>/<仓库名称>

修改仓库描述

你可以使用 gh repo edit 命令修改仓库的描述信息。具体命令格式如下:

1
gh repo edit <用户名>/<仓库名> --description "新的描述信息"
修改仓库的可见性

若要把仓库从公开变为私有,或者从私有变为公开,可使用 --visibility 参数。公开仓库使用 public,私有仓库使用 private。示例如下:

  • 将 wzl-GitHubs/ubuntu-ssh 仓库变为私有:
1
gh repo edit wzl-GitHubs/ubuntu-ssh --visibility private
  • 将 wzl-GitHubs/ubuntu-ssh 仓库变为公开:
1
gh repo edit wzl-GitHubs/ubuntu-ssh --visibility public
启用或禁用仓库的某些功能
  • 启用或禁用 Issues 功能:使用 --enable-issues 或 --disable-issues 参数。例如,启用 wzl-GitHubs/ubuntu-ssh 仓库的 Issues 功能:
1
gh repo edit wzl-GitHubs/ubuntu-ssh --enable-issues
  • 启用或禁用 Wiki 功能:使用 --enable-wiki 或 --disable-wiki 参数。例如,禁用 wzl-GitHubs/ubuntu-ssh 仓库的 Wiki 功能:
1
gh repo edit wzl-GitHubs/ubuntu-ssh --disable-wiki
添加或修改仓库主页链接

使用 --homepage 参数可以添加或修改仓库的主页链接。示例如下,为 wzl-GitHubs/ubuntu-ssh 仓库添加主页链接:

1
gh repo edit wzl-GitHubs/ubuntu-ssh --homepage "https://example.com"

github基础配置

安装git

在终端输入

1
sudo apt-get install git

测试ssh

在终端输入

1
ssh -T git@github.com

git@github.com: Permission denied (publickey).

这时候需要建立公钥

创建公钥

1
ssh-keygen -C "xx@xx.com" -f ~/.ssh/github

查看公钥

1
cat ~/.ssh/github.pub

上传公钥

登陆github操作

1
gh auth login

过程需要手机验证

? What account do you want to log into? GitHub.com 选择ssh
? What is your preferred protocol for Git operations on this host? SSH ? Upload your SSH public key to your GitHub account? /home/wzl/.ssh/github.pub ? Title for your SSH key: GitHub CLI ? How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens 点击生成token
The minimum required scopes are 'repo', 'read:org', 'admin:public_key'.选择token ? Paste your authentication token:

登陆成功

? Paste your authentication token: ********************************************************************- gh config set -h github.com git_protocol ssh ✓ Configured git protocol ✓ SSH key already existed on your GitHub account: /home/wzl/.ssh/github.pub ✓ Logged in as wzl-GitHubs

账号验证

1
ssh -T git@github.com

Hi wzl-GitHubs! You've successfully authenticated, but GitHub does not provide shell access.

列出你自己的所有仓库

1
gh repo list --owner <你的用户名>

linux常用命令

Linux 文件系统命令 API 文档

1. 概述

本 API 文档涵盖了常见的 Linux 文件系统命令,这些命令用于文件和目录的操作、文件内容查看、权限管理、文件系统挂载等操作。

2. 文件和目录操作

2.1 ls - 列出目录内容

  • 功能:列出指定目录中的文件和子目录。
  • 语法ls [选项] [目录]
  • 选项
    • -l:以长格式显示文件和目录信息,包括权限、所有者、大小、修改时间等。
    • -a:显示所有文件和目录,包括隐藏文件(以 . 开头的文件)。
    • -h:与 -l 一起使用时,以人类可读的格式显示文件大小(如 KB、MB 等)。
    • -R:递归列出指定目录及其子目录中的所有文件和目录。
  • 示例
    • ls:列出当前目录中的文件和目录。
    • ls -l:以长格式显示当前目录中的文件和目录信息。
    • ls -la /home/user:以长格式显示 /home/user 目录中的所有文件和目录信息。

2.2 mkdir - 创建目录

  • 功能:创建一个新的目录。
  • 语法mkdir [选项] 目录名
  • 选项
    • -p:如果父目录不存在,则创建父目录。
  • 示例
    • mkdir new_dir:在当前目录下创建一个名为 new_dir 的目录。
    • mkdir -p parent_dir/child_dir:如果 parent_dir 不存在,则创建 parent_dir,并在其中创建 child_dir

2.3 rm - 删除文件或目录

  • 功能:删除指定的文件或目录。
  • 语法rm [选项] 文件或目录
  • 选项
    • -r:递归删除目录及其所有子目录和文件。
    • -f:强制删除,不提示确认信息。
  • 示例
    • rm file.txt:删除当前目录下的 file.txt 文件。
    • rm -r dir:递归删除 dir 目录及其所有内容。
    • rm -rf dir:强制递归删除 dir 目录及其所有内容,不提示确认信息。

2.4 mv - 移动或重命名文件或目录

  • 功能:将文件或目录从一个位置移动到另一个位置,或者重命名文件或目录。
  • 语法mv [选项] 源文件或目录 目标文件或目录
  • 选项
    • -i:在覆盖目标文件之前提示确认信息。
  • 示例
    • mv file.txt new_dir/:将 file.txt 文件移动到 new_dir 目录中。
    • mv old_name.txt new_name.txt:将 old_name.txt 文件重命名为 new_name.txt

2.5 cp - 复制文件或目录

  • 功能:复制文件或目录。
  • 语法cp [选项] 源文件或目录 目标文件或目录
  • 选项
    • -r:递归复制目录及其所有子目录和文件。
    • -i:在覆盖目标文件之前提示确认信息。
  • 示例
    • cp file.txt new_file.txt:将 file.txt 文件复制为 new_file.txt
    • cp -r dir new_dir:递归复制 dir 目录及其所有内容到 new_dir 目录中。

3. 文件内容查看

3.1 cat - 显示文件内容

  • 功能:将文件的内容输出到标准输出。
  • 语法cat [选项] 文件
  • 选项
    • -n:显示行号。
  • 示例
    • cat file.txt:显示 file.txt 文件的内容。
    • cat -n file.txt:显示 file.txt 文件的内容,并显示行号。

3.2 more - 分页显示文件内容

  • 功能:分页显示文件的内容,按空格键翻页。
  • 语法more 文件
  • 示例more large_file.txt:分页显示 large_file.txt 文件的内容。

3.3 less - 分页显示文件内容

  • 功能:分页显示文件的内容,支持向前和向后翻页,功能比 more 更强大。
  • 语法less 文件
  • 示例less big_file.txt:分页显示 big_file.txt 文件的内容。

3.4 head - 显示文件开头的内容

  • 功能:显示文件开头的指定行数,默认显示前 10 行。
  • 语法head [选项] 文件
  • 选项
    • -n 行数:指定显示的行数。
  • 示例
    • head file.txt:显示 file.txt 文件的前 10 行。
    • head -n 5 file.txt:显示 file.txt 文件的前 5 行。

3.5 tail - 显示文件末尾的内容

  • 功能:显示文件末尾的指定行数,默认显示后 10 行。还可以实时跟踪文件的新增内容。
  • 语法tail [选项] 文件
  • 选项
    • -n 行数:指定显示的行数。
    • -f:实时跟踪文件的新增内容。
  • 示例
    • tail file.txt:显示 file.txt 文件的后 10 行。
    • tail -n 5 file.txt:显示 file.txt 文件的后 5 行。
    • tail -f log.txt:实时跟踪 log.txt 文件的新增内容。

4. 文件权限管理

4.1 chmod - 修改文件或目录的权限

  • 功能:修改文件或目录的权限,包括读(r)、写(w)、执行(x)权限。
  • 语法chmod [选项] 权限模式 文件或目录
  • 选项
    • -R:递归修改目录及其所有子目录和文件的权限。
  • 权限模式
    • 数字模式:如 755 表示所有者具有读、写、执行权限,组用户和其他用户具有读、执行权限。
    • 符号模式:如 u+x 表示给所有者添加执行权限。
  • 示例
    • chmod 755 script.sh:将 script.sh 文件的权限设置为 755。
    • chmod -R 777 dir:递归将 dir 目录及其所有内容的权限设置为 777。
    • chmod u+x file.sh:给 file.sh 文件的所有者添加执行权限。

4.2 chown - 修改文件或目录的所有者

  • 功能:修改文件或目录的所有者。
  • 语法chown [选项] 新所有者 文件或目录
  • 选项
    • -R:递归修改目录及其所有子目录和文件的所有者。
  • 示例
    • chown new_user file.txt:将 file.txt 文件的所有者修改为 new_user
    • chown -R new_user dir:递归将 dir 目录及其所有内容的所有者修改为 new_user

4.3 chgrp - 修改文件或目录的所属组

  • 功能:修改文件或目录的所属组。
  • 语法chgrp [选项] 新组名 文件或目录
  • 选项
    • -R:递归修改目录及其所有子目录和文件的所属组。
  • 示例
    • chgrp new_group file.txt:将 file.txt 文件的所属组修改为 new_group
    • chgrp -R new_group dir:递归将 dir 目录及其所有内容的所属组修改为 new_group

5. 文件系统挂载与卸载

5.1 mount - 挂载文件系统

  • 功能:将文件系统挂载到指定的挂载点。
  • 语法mount [选项] 设备名 挂载点
  • 选项
    • -t 文件系统类型:指定要挂载的文件系统类型,如 ext4ntfs 等。
  • 示例
    • mount /dev/sdb1 /mnt:将 /dev/sdb1 设备挂载到 /mnt 目录。
    • mount -t ntfs /dev/sdb1 /mnt:将 /dev/sdb1 设备的 NTFS 文件系统挂载到 /mnt 目录。

5.2 umount - 卸载文件系统

  • 功能:卸载已挂载的文件系统。
  • 语法umount [选项] 设备名或挂载点
  • 示例
    • umount /mnt:卸载挂载在 /mnt 目录的文件系统。
    • umount /dev/sdb1:卸载 /dev/sdb1 设备上的文件系统。

6. 文件搜索

6.1 find - 在目录中搜索文件

  • 功能:在指定目录及其子目录中搜索符合条件的文件。
  • 语法find [目录] [选项] [条件]
  • 选项和条件
    • -name 文件名:按文件名搜索,支持通配符,如 *.txt
    • -type 文件类型:按文件类型搜索,如 f 表示普通文件,d 表示目录。
    • -size 文件大小:按文件大小搜索,如 +10M 表示大于 10MB 的文件。
  • 示例
    • find /home -name "*.txt":在 /home 目录及其子目录中搜索所有扩展名为 .txt 的文件。
    • find /var -type d:在 /var 目录及其子目录中搜索所有目录。
    • find /tmp -size +10M:在 /tmp 目录及其子目录中搜索所有大于 10MB 的文件。

6.2 grep - 在文件中搜索字符串

  • 功能:在文件中搜索包含指定字符串的行。
  • 语法grep [选项] 字符串 文件
  • 选项
    • -i:忽略大小写。
    • -r:递归搜索目录及其子目录中的文件。
  • 示例
    • grep "error" log.txt:在 log.txt 文件中搜索包含 error 的行。
    • grep -i "warning" logs/:递归在 logs 目录及其子目录中的文件中搜索包含 warning 的行,忽略大小写。

7. 文件系统检查与修复

7.1 fsck - 检查并修复文件系统

  • 功能:检查并修复文件系统的错误。
  • 语法fsck [选项] 设备名
  • 选项
    • -y:自动修复所有错误,不提示确认信息。
  • 示例fsck -y /dev/sda1:自动检查并修复 /dev/sda1 设备上的文件系统错误。

7.2 xfs_repair - 修复 XFS 文件系统

  • 功能:专门用于修复 XFS 文件系统的错误。
  • 语法xfs_repair [选项] 设备名
  • 示例xfs_repair /dev/sdb2:修复 /dev/sdb2 设备上的 XFS 文件系统错误。

8. 磁盘使用情况查看

8.1 df - 显示文件系统的磁盘使用情况

  • 功能:显示文件系统的磁盘使用情况,包括总容量、已使用容量、可用容量等。
  • 语法df [选项]
  • 选项
    • -h:以人类可读的格式显示磁盘容量(如 KB、MB、GB 等)。
  • 示例df -h:以人类可读的格式显示所有文件系统的磁盘使用情况。

8.2 du - 显示文件或目录的磁盘使用情况

  • 功能:显示文件或目录的磁盘使用情况。
  • 语法du [选项] 文件或目录
  • 选项
    • -h:以人类可读的格式显示磁盘容量。
    • -s:只显示总计大小。
  • 示例
    • du -h dir:以人类可读的格式显示 dir 目录及其子目录的磁盘使用情况。
    • du -sh dir:以人类可读的格式显示 dir 目录的总计磁盘使用情况。

Mamba安装与使用

1 Mamba 是一个快速、强大且跨平台的包管理器

兼容conda速度比conda更快

它可以在 WindowsOS XLinux(包括 ARM64PPC64LE)上运行,并且与软件包完全兼容并支持大多数 conda 的命令。conda

Mamba 是一个包含多个组件的框架:

  • libmamba:域的 C++ 库,公开低级和高级 API

  • mamba:ELF 作为 的直接替代品,构建在conda``libmamba

  • micromamba:静态链接的版本mamba

  • libmambapy:Python 的绑定libmamba

2 下载micromamba

1
2
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
bin/micromamba

3 设置micromamba的环境变量

建议安装在/opt目录

1
2
sudo mkdir -p /opt/micromamba/bin
sudo mv ./bin/* /opt/micromamba/bin

修改权限

1
sudo chmod a+x /opt/micromamba/bin/*

执行环境初始化

1
2
/opt/micromamba/bin/micromamba shell init -s bash -r ~/micromamba # 设置`micromamba`的环境变量
source ~/.bashrc # 刷新配置

4 查看micromamba版本

1
micromamba -v

5 为micromamba创建conda虚拟环境软连接

以下配置按个人所需,因为micromamba并不会扫描以有conda的虚拟环境,需要手动创建连接文件

(1)conda查看虚拟环境
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
conda info --envs   # conda查看虚拟环境
# 这是我的虚拟环境
# conda environments:
#
# base /opt/miniconda3
# R1 * /opt/miniconda3/envs/R1
# 可判断我的conda虚拟环境在/opt/miniconda3/envs目录下


micromamba info --envs # micromamba查看虚拟环境

# Name Active Path
# ──────────────────────────────────────────────
# base /home/wzl/micromamba
# 可判断我的micromamba虚拟环境在/home/wzl/micromamba目录下
(2) 根据虚拟环境创建软连接 -按个人环境执行-
1
ln -s /opt/miniconda3/envs /home/wzl/micromamba # 
(3)查看虚拟环境是否加载
1
2
3
4
5
6
micromamba info --envs # micromamba查看虚拟环境
# Name Active Path
#──────────────────────────────────────────────
# base /home/wzl/micromamba
# R1 /home/wzl/micromamba/envs/R1
# * /opt/miniconda3/envs/R1 # 成功添加conda环境
(4) 快捷命令配置
1
vim ~/.bashrc

追加内容

1
2
3
4
alias ma="micromamba activate" 
alias mda="micromamba deactivate"
alias minfo="micromamba info --envs"
# ESC:wq 保存并退出
1
source ~/.bashrc # 刷新配置

查看minfo命令是否生效

1
2
3
4
5
6
minfo
# Name Active Path
#──────────────────────────────────────────────
# base /home/wzl/micromamba
# R1 /home/wzl/micromamba/envs/R1
# /opt/miniconda3/envs/R1

github代码提交

创建带有描述的仓库

如果你想在创建仓库时添加描述信息,可以使用 --description 参数。示例如下,创建一个名为 new-desc-repo 且带有描述信息的公开仓库:

bash

1
gh repo create new-desc-repo --public --description "这是一个带有描述的新仓库"

删除仓库

1
gh repo delete <用户名>/<仓库名称>

提交代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 初始化本地仓库
cd test-project
git init

# 关联远程仓库
git remote add origin git@github.com:wzl-GitHubs/test-project.git
# 例如
git remote add origin 'https://github.com/wzl-GitHubs/biji.git'

# 编写代码...

# 修改编码
git config --global core.quotepath
git config --global core.quotepath false

# 查看文件状态
git status

# 暂存所有修改的文件
git add .

# 配置全局作者信息
git config --global user.email "you@example.com"
git config --global user.name "Your Name"

# 提交到本地仓库
git commit -m "完成项目初始搭建"

# 首次提交需要创建主分支
git checkout -b main
# 将本地的 main 分支推送到远程
git push -u origin main
# 然后需要选择提交方式

输入创建的token名
Username for 'https://github.com': https://github.com
输入token
Password for 'https://https%3A%2F%2Fgithub.com@github.com':

示例流程

假设你要对 main 分支进行二次提交,操作步骤如下:

bash

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 查看文件状态
git status

# 添加所有更改的文件到暂存区
git add .

# 提交暂存区的文件到本地仓库
git commit -m "更新 bug"

# 拉取远程仓库的最新代码
git pull origin main

# 推送本地代码到远程仓库
git push origin main

在手机上安装android-sdk,配置java,执行appium自动化任务

本章主要是aarch64架构android-sdk的收集,当然基于terxux的android-sdk工具包本人已经做好,日后会在我的服务器上发布,供大家下载安装,本章节主要分享怎么搜集aarch64架构android-sdk,后续会续写制作deb安装包的教程。

上篇博客appium安装教程-CSDN博客的配置请保证已完成。

上节我们成功启动了appium服务,但通过appium-doctor验证appium依赖发现我们还需要安装android-sdkjava,本节以主要介绍为android平台的termux收集aarch64架构的android-sdk包,并安装java,同学!请上车。

1 termux(安卓平台)下载android工具包

一, 安装android-sdkcmdline-tools

最好是在终端执行命令,因为包比较零散,手动创建目录比较麻烦。

termux 有几个重要的环境变量需要了解,不然你还真不知道$HOME``$PREFIX指的是什么

1
2
$HOME=/data/data/com.termux/files/home
$PREFIX=/data/data/com.termux/files/usr

android-sdk

1
2
3
4
5
Android SDK:开发安卓应用的工具集,含工具、库、文档、模拟器等,支持多种语言开发。
Cmdline-tools:SDK 里的命令行工具,用于命令行执行开发操作、自动化构建。
Build-tools:构建安卓应用的工具,能编译、打包、签名应用,支持不同配置。
Platform-tools:与安卓平台相关的工具集,含adb,用于设备通信、调试、文件传输。
bundletool.jar:处理安卓 App Bundle 的工具,可将其转为 APK,还能做分析处理。
1.1 终端执行(以aarch64为例,因为符合大多数手机的架构)
1
2
3
4
mkdir -p $HOME/android/android_cache # 创建缓存目录
cd $HOME/android/android_cache # 进入缓存目录
wget https://github.com/AndroidIDEOfficial/androidide-tools/releases/download/sdk/android-sdk.tar.xz
wget https://github.com/AndroidIDEOfficial/androidide-tools/releases/download/sdk/cmdline-tools.tar.xz
1.2 手动下载下载

从这里下载并安装 termux

此处下载android-sdkcmdline-tools

二, 下载 build-tools platform-toolsbundletool.jar
2.1 终端执行(以aarch64为例)
1
2
3
4
5
cd $HOME/android/android_cache # 确保在缓存目录下
wget https://github.com/AndroidIDEOfficial/androidide-tools/releases/download/v33.0.3/build-tools-33.0.3-aarch64.tar.xz
wget https://github.com/AndroidIDEOfficial/androidide-tools/releases/download/v33.0.3/platform-tools-33.0.3-aarch64.tar.xz
### 因为标准的linux中有tools/bundletool.jar包,所以咱们也不能少,在2.2中有详细的介绍
wget https://github.com/google/bundletool/releases/download/1.18.1/bundletool-all-1.18.1.jar
2.2手动下载

根据你的平台架构在这里下载 build-toolsplatform-tools

因为标准的android-sdk-linux中有tools/bundletool.jar包,所以咱们也不能少。
bundletool 科普在这

bundletool.jar开源地址在这

三, 提取包

提取android-sdkcmdline-toolsbuild-toolsplatform-tools拷贝bundletool.jar

1
2
3
4
5
6
7
cd $HOME/android/android_cache # 确保在缓存目录
tar -Jxvf android-sdk.tar.xz -C ..
tar -Jxvf cmdline-tools.tar.xz -C ../android-sdk
tar -Jxvf build-tools-33.0.3-aarch64.tar.xz -C ../android-sdk
tar -Jxvf platform-tools-33.0.3-aarch64.tar.xz -C ../android-sdk
mkdir -p $HOME/android/android-sdk/tools # 创建bundletool.jar目录
cp bundletool-all-1.18.1.jar ../android-sdk/tools/bundletool.jar

至此我们已经将android-sdk的包收集完毕,具体在$HOME/android/android-sdk下这个目录不是很安全,容易操作失误导致文件丢失,所以建议将android-sdk放在/data/data/com.termux/files/opt目录下,也就是$PREFIX/../opt目录。

android-sdk移动到目录 opt目录下

1
2
3
# 创建opt目录
mkdir -p $PREFIX/../opt
mv $HOME/android/android-sdk $PREFIX/../opt

四, 配置环境变量

1
2
export ANDROID_HOME=$PREFIX/../opt/android-sdk 
export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH

收集aarch64平台sdk的工作终于结束!!!!!!!

2 termux(安卓平台)安装java

安装java
1
2
pkg search jdk #查询官方提供的JDK 
pkg install openjdk-17
配置java环境变量

由于termux并不是纯净的linux环境,配置java环境变量建议使用方式一配置,这里提供两种java环境变量的配置方法,请按照你的使用习惯选择。

方式一
1
vim ~/.bashrc # 粘贴以下内容
1
2
3
export JAVA_HOME=$PREFIX/lib/jvm/java-17-openjdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$CLASSPATH

这样配置java环境变量,在proot和初始shell中都可以使用,但不符合linux的使用规范。

1
java -version
方式二

只能在proot环境使用java但符合liunx使用规范。

1
2
3
4
# 安装proot
pkg update
pkg install proot
vim ~/.bashrc # 粘贴以下内容
1
2
3
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$CLASSPATH

这样配置每次使java需要进入proot环境,

1
2
termux-chroot
java -version
  • 注意 两种环境变量的差异就在$PREFIX变量,首先PREFIX=/data/data/com.termux/usr,因为termux默认的shell/data/data/com.termux/usr/bin/bashtermuxhome目录在/data/data/com.termux/files/home目录,由于android系统对用户权限的限制,普通用户是无法访问/目录的,所以普通用户不能使用PATH=/usr/lib/jvm/java-17-openjdk的环境变量,而proot是将是将空间隔离,重新定义了/目录,并将/data/data/com.termux/目录挂在在自己环境的/目下,这样我们既可以通过$PREFIX访问usr目录,也可以使用/usr访usr目录。

下一章节实现客户端和服务端的通信,然后搭建自动化测试服务。

上一节传送门

下一节传送门

感谢的技术支持Install-Android-Studio-in-Termux

感谢来自以下博客的分享

bundletool 工具使用详解-CSDN博客

Linux环境下安装appium测试工具_linux安装appium-CSDN博客

npm安装appium

本章节以严谨的先后逻辑一步一步实现从termux (安卓平台), windowslinux搭建appium服务。

1 安装 node.js

首次安装node.js ,因为appium是基于node.js的工具,而npmnode.js的包管理工具,考虑到node.js优秀的跨平台性,本章节主要以npm实现appium服务的搭建(当然像apt也可以安装,但是只适合ubuntu操作系统)

termux安装命令

1
pkg install nodejs #以下操作termux用户去掉sudo即可

ubuntu安装命令

别用apt安装nodejs,因为apt收录的nodejs版本太低,建议直接区官网下载NodeJs官方教程, 下面是终端下载流程

1
2
3
4
5
6
7
sudo apt update 
sudo apt install wget # 下载wget
wget -o https://nodejs.org/dist/v22.14.0/node-v22.14.0-linux-x64.tar.xz #下载nodejs
sudo tar -Jxvf node-v22.14.0-linux-x64.tar.xz -C /opt/ # 解压nodejs
sudo chmod -R 744 /opt/node-v22.14.0-linux-x64 # 修改权限
sed -i '$a\PATH=/opt/node-v22.14.0-linux-x64/bin:$PATH' ~/.bashrc # 配置环境变量
source ~/.bashrc # 刷新配置

windows安装命令

1
winget install OpenJs.NodeJs

2 验证node.js安装

1
2
node -v
npm -v

3 npm换源

更换淘宝镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
npm config set registry https://registry.npmmirror.com
# 如果有问题执行两次 # npm config set registry https://registry.npmmirror.com
# npm config get registry # 查看当前的镜像源
# npm config set registry [url] 设置镜像站

### 常见源
#官方镜像:https://registry.npmjs.org/
#淘宝镜像:http://registry.npmmirror.com
#阿里镜像:https://npm.aliyun.com
#腾讯镜像:https://mirrors.cloud.tencent.com/npm/
#华为镜像:https://mirrors.huaweicloud.com/repository/npm/
#网易镜像:https://mirrors.163.com/npm/
#清华镜像:https://mirrors.tuna.tsinghua.edu.cn/
#中科大镜像:http://mirrors.ustc.edu.cn/

4 设置npm包管理路径

1
2
3
4
5
6
7
8
npm config set prefix  ~/npm_prefix
npm config set cache ~/npm_cache

#npm config set prefix "$file_path/prefix" # 设置包安装路径
#npm config set cache "$file_path/cache" # 设置npm缓存路径
npm config ls # 查看npm包管理环境配置
# npm cache clean --force # 清理缓存,如果报错说明权限有问题,找一下Ai
# 或者直接到 ~/npm_cache目录下删除所有文件

5 安装appium

1
2
3
npm install -g appium
# 安装appium-doctor验证appium依赖
npm install -g appium-doctor

6 配置appium

1
2
sed -i '$a\PATH=$HOME/npm_prefix/bin:$PATH' ~/.bashrc #配置appium环境变量
source ~/.bashrc
1
2
#打开appium
appium
1
2
# 打开appium-doctor
appium-doctor

安装驱动与插件

1
2
3
4
appium driver list # 查看驱动库
appium driver install uiautomator2# 安装uiautomator2驱动
appium plugin list # 查看插件库
appium plugin install universal-xml # 安装universal-xml插件

附带插件启动appium

1
appium --use-plugins universal-xml

使用appium-docter检查appium环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[Deprecated] Please use appium-doctor installed with "npm install @appium/doctor --location=global"
info AppiumDoctor Appium Doctor v.1.16.2
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor ✔ The Node.js binary was found at: /opt/node-v22.14.0-linux-x64/bin/node
info AppiumDoctor ✔ Node version is 22.14.0
info AppiumDoctor ✔ ANDROID_HOME is set to: /opt/android-sdk-linux
WARN AppiumDoctor ✖ JAVA_HOME environment variable is NOT set!
info AppiumDoctor Checking adb, android, emulator, apkanalyzer
info AppiumDoctor 'adb' is in /opt/android-sdk-linux/platform-tools/adb
info AppiumDoctor 'android' is in /opt/android-sdk-linux/tools/android
info AppiumDoctor 'emulator' is in /opt/android-sdk-linux/tools/emulator
WARN AppiumDoctor ✖ apkanalyzer could NOT be found in /opt/android-sdk-linux!
WARN AppiumDoctor ✖ Cannot check $JAVA_HOME requirements since the environment variable itself is not set
info AppiumDoctor ### Diagnostic for necessary dependencies completed, 3 fixes needed. ###
info AppiumDoctor
info AppiumDoctor ### Diagnostic for optional dependencies starting ###
WARN AppiumDoctor ✖ opencv4nodejs cannot be found.
WARN AppiumDoctor ✖ ffmpeg cannot be found
WARN AppiumDoctor ✖ mjpeg-consumer cannot be found.
WARN AppiumDoctor ✖ bundletool.jar cannot be found
info AppiumDoctor ✔ gst-launch-1.0 and gst-inspect-1.0 are installed at: /usr/bin/gst-launch-1.0 and /usr/bin/gst-inspect-1.0
info AppiumDoctor ### Diagnostic for optional dependencies completed, 4 fixes possible. ###
info AppiumDoctor
info AppiumDoctor ### Manual Fixes Needed ###
info AppiumDoctor The configuration cannot be automatically fixed, please do the following first:
WARN AppiumDoctor ➜ Make sure the environment variable JAVA_HOME is properly configured for the Appium process. Refer https://github.com/appium/java-client/blob/master/docs/environment.md for more details.
WARN AppiumDoctor ➜ Manually install apkanalyzer and add it to PATH. https://developer.android.com/studio#cmdline-tools and https://developer.android.com/studio/intro/update#sdk-manager may help to setup.
WARN AppiumDoctor ➜ Set $JAVA_HOME environment variable to the root folder path of your local JDK installation
info AppiumDoctor
info AppiumDoctor ### Optional Manual Fixes ###
info AppiumDoctor The configuration can install optionally. Please do the following manually:
WARN AppiumDoctor ➜ Why opencv4nodejs is needed and how to install it: http://appium.io/docs/en/writing-running-appium/image-comparison/
WARN AppiumDoctor ➜ ffmpeg is needed to record screen features. Please read https://www.ffmpeg.org/ to install it
WARN AppiumDoctor ➜ mjpeg-consumer module is required to use MJPEG-over-HTTP features. Please install it with 'npm i -g mjpeg-consumer'.
WARN AppiumDoctor ➜ bundletool.jar is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it
info AppiumDoctor
info AppiumDoctor ###
info AppiumDoctor
info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!
info AppiumDoctor

由于没有装android-sdk,与java。所以虽然服务启动了,但无法使用下节开始配置sdk并安装java

注意

termux用户在执行安装的时候别加sudo哦

有问题积极留言讨论

感谢来自以下博客的分享

npm 设置全局变量安装路径及环境配置_无配置自定义npm路径,npm路径将用系统环境变量路径-CSDN博客

ubuntu:安装配置appium全套流程(亲测有效)_ubuntu安装appium-CSDN博客

国内npm源镜像(npm加速下载) 指定npm镜像_npm国内镜像源-CSDN博客

为网站部署数字证书

一, 数字证书申请

1. 安装Certbot(以Ubuntu为例)

1
2
sudo apt update
sudo apt install certbot python3-certbot-nginx

2. 申请证书(Nginx为例)

1
sudo certbot --nginx -d yourdomain.com -d 你的域名

3. 自动续期测试

1
sudo certbot renew --dry-run
1
2
3
4
5
6
7
8
通常 Certbot 生成的证书路径如下:

/etc/letsencrypt/live/yourdomain.com/
├── fullchain.pem # 证书链(包含域名证书+中间证书)
├── privkey.pem # 私钥文件
├── cert.pem # 域名证书(不含中间证书)
└── chain.pem # 中间证书
关键文件:fullchain.pem + privkey.pem

4. Nginx 基础 HTTPS 配置

编辑 Nginx 配置文件(通常位于 /etc/nginx/conf.d/):

1
2
cd /etc/nginx/conf.d/ 
ls -al # 查看nginx配置文件

打开配置文件(没有的话直接vim创建),调整内容粘贴仔细查看括号中的内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# HTTPS 配置块
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.wzl.com wzl.com; #(这里按照你的域名修改)

# SSL 证书路径 (这里按照你的证书地址修改)
ssl_certificate /etc/letsencrypt/live/wzl.homes/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/wzl.homes/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

# 静态文件路径(这里按照你的情况修改)
root $path; # $path指的是你映射的目录
index index.html;# 你加载的静态文件

location / {
try_files $uri $uri/ =404;
}
}

# HTTP 跳转 HTTPS 配置块 (这里按照你的域名修改)
server {
listen 80;
listen [::]:80;
server_name www.wzl.com wzl.com;# (这里按照你的域名修改)

# 强制跳转到 HTTPS
return 301 https://$host$request_uri;
}

5. 重启nginx服务

1
sudo nginx -t && sudo systemctl restart nginx

6. 验证证书状态

浏览器访问:www.wzl.com# 指你的域名

命令行检测:

1
curl -I https://wzl.com

逾期输出:

1
2
3
4
5
6
7
8
9
HTTP/1.1 200 OK # 表明证书配置好了
Server: nginx/1.20.1
Date: Sun, 20 Apr 2025 06:02:46 GMT
Content-Type: text/html
Content-Length: 78995
Last-Modified: Sun, 20 Apr 2025 05:15:26 GMT
Connection: keep-alive
ETag: "680482ee-13493"
Accept-Ranges: bytes