一、 server环境搭建
1.1 simple环境配置【PS:现已整合进Server,详见 Part7 最新版代码环境配置记录】
1.1.1 JDK配置
git地址:https://github.com/SonicCloudOrg/sonic-server-simple
jdk版本:15(可直接从IDEA下载jdk版本,IDEA版本须大于2020.1)

具体各项配置项详见:https://note.youdao.com/s/GuSZmueL(注:所有jdk均选择15)
1.1.2 MYSQL环境配置
本地配置mysql详见:https://note.youdao.com/s/dlNtWRR4
项目配置mysql:

本地新建 sonic库,账户名密码需配置一致
可使用MYSQL workbench 方便快捷操作数据库;

运行项目:

环境配置成功!!
二、 web环境搭建
igit地址:https://github.com/SonicCloudOrg/sonic-client-web.git
2.1 升级npm版本
参考:https://blog.csdn.net/ben_grf/article/details/121328363升级node版本
依赖npm版本为:8.6.0
升级npm版本至8.6.0: npm install -g npm@8.6.0
报错如下:
ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'agentkeepalive'
npm ERR! Require stack:
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/make-fetch-happen/index.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/remote.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/git.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/fetcher.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/index.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/lib/utils/update-notifier.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/lib/cli.js
npm ERR! - /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/meng/.npm/_logs/2022-04-14T06_48_13_320Z-debug.log
解决方案:
a) 安装 agentkeepalive 模块,安装命令是:npm install -g agentkeepalive
b) 更新npm版本,npm install -g npm@8.6.0

2.2 运行项目
npm install
npm run dev


三、 agent环境搭建
3.1 新增agent
运行sonic simple及web项目,新注册一个agent,获取agent key

3.2 配置agent项目
3.2.1 代码环境配置
igit地址:https://github.com/SonicCloudOrg/sonic-agent.git
修改pom文件中默认jdk版本:

jdk:15
项目jdk配置:参考simple项目jdk环境配置
3.2.2 修改application-prod.yml文件
两个地方的配置文件:
application-prod.yml及application-dev.yml


3.2.3 运行项目,报错检查 ANDROID_HOME 环境变量不通过

解决方案:
安装android studio
android sdk环境变量配置:

android sdk存放地址查看(Android studio):

已经配置ANDROID_HOME但是idea还是获取不到,可参考以下方式:

3.2.4 Chromedriver配置
参考:http://t.zoukankan.com/mecell224-p-11123746.html

3.2.5 其他配置
appium:npm i -g appium
adbkit:npm i -g adbkit
1) 连接到服务器10.252.224.71:8095失败!10s后重连...

查看simple项目运行日志,发现如下错误:

解决方案:
暂未解决
四、 WDA环境配置
TODO
五、 整体环境流程顺序
● 搭建simple环境,jdk15,
● 起web项目,配置vue、npm、node环境,执行npm start dev
● web+simple环境配置好以后,新增一个agent,记住该agent的key
● 起agent项目,修改application-prod.yml配置文件
5.1 整体联调问题记录
问题1:

安装tidevice工具,通过tidevice applist查看手机包名与自己配置的wda的id是否一致
下载 tidevice
pip3 install tidevice -i https://pypi.douban.com/simple


问题2:

-[UITestingUITests internalImplementation]: unrecognized selector sent to instance 0x2834ee3a0
2022-04-20 20:14:59.446 - INFO 9874 --- [http-nio-7777-exec-1] o.cloud.sonic.agent.bridge.ios.SibTool : 2022-04-20 20:14:59.213971+0800 WebDriverAgentRunner-Runner[432:16165] Enqueue Failure: -[UITestingUITests internalImplementation]: unrecognized selector sent to instance 0x2834ee3a0 (NSInvalidArgumentException) (null) 0 0
解决方案参考:https://www.cnblogs.com/hlikex/p/13113499.html

// self.internalImplementation = (_XCTestCaseImplementation *)[FBXCTestCaseImplementationFailureHoldingProxy proxyWithXCTestCaseImplementation:self.internalImplementation];
if ([self respondsToSelector:@selector(internalImplementation)]) {
// The `internalImplementation` API has been removed since Xcode 11.4
self.internalImplementation =
(_XCTestCaseImplementation *)[FBXCTestCaseImplementationFailureHoldingProxy
proxyWithXCTestCaseImplementation:self.internalImplementation];
} else {
self.shouldHaltWhenReceivesControl = NO;
}
六、 sonic-server 环境配置
6.1 项目基础配置
git地址:https://github.com/SonicCloudOrg/sonic-server
参考:https://note.youdao.com/ynoteshare/index.html?id=efc92ef7bce7a92d4f1f3055b4d4012c&type=note&_time=1654150192152
补充错误记录:
1) 打包server时报错:
Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.lang.UnsatisfiedLinkError: could not load FFI provider com.spotify.docker.client.shaded.jnr.ffi.provider.jffi.Provider: ExceptionInInitializerError: Can't overwrite cause with java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: /private/var/folders/fm/753d4pcj36bfws8rj8nhk1gc0000gn/T/jffi1899457535920988535.dylib: dlopen(/private/var/folders/fm/753d4pcj36bfws8rj8nhk1gc0000gn/T/jffi1899457535920988535.dylib, 1): no suitable image found. Did find:

解决方法:https://blog.csdn.net/yrwan95/article/details/122193187
注意刚配完环境变量后,idea可能还获取不到,这时候关掉idea,重新通过命令行打开idea即可;
open /Applications/IntelliJ\ IDEA.app
2) 打包server时报错
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (imageBuild) on project sonic-server-controller: Exception caught: Head "https://registry-1.docker.io/v2/adoptopenjdk/openjdk15/manifests/alpine": EOF -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :sonic-server-controller
docker新增源:

{
"debug": true,
"experimental": false,
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://6kx4zyno.mirror.aliyuncs.com"
]
}
3) server 打包时报错
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (imageBuild) on project sonic-server-controller: Exception caught: no matching manifest for linux/arm64/v8 in the manifest list entries -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :sonic-server-controller
在m1使用docker的镜像的时候,如果不支持linux/arm64/v8会提示上面内容,
解决方案:使用支持linux/arm64/v8架构的镜像
https://hub.docker.com/,docker镜像源地址


重新build,成功!
3) server打包时报错

七、 最新版代码环境配置记录
7.1 sonic-server
7.1.1 IDEA相关项目配置




7.1.2 修改代码文档配置








7.1.3 打包
首先 common打包

common打包完毕后,将common包移至自己的repository

执行server下的打包

首先本地搭建docker环境,然后搭建过程中要是存在报错可以第六节:sonic-server环境配置
注:1) 检查docker是否安装成功运行
2)docker是否登录
3)打包时要是一直下载jdk15失败,可本地docker下载

检查docker镜像:

7.1.4 运行项目
运行eureka

运行 Gateway
运行 Folder
运行controller
7.2 web项目
参考第2节 web环境搭建


7.3 agent项目






