远程控制手机过程中使用了scrcpy-server,由于之前使用的scrcpy-server版本较低,需要升级至1.19,但是新版本没有输出pid进程信息,所以需要增加pid信息输出,并重新编译打包。
编译打包需要用到gradle, 记录一下操作过程。
1. 下载源码,scrcpy 1.19
2. 修改相关国内镜像,默认配置maven都是官网的,直接编译会失败
build.gradle
buildscript {
repositories {
// google()
// jcenter()
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
//google()
//jcenter()
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/public' }
}
tasks.withType(JavaCompile) {
options.compilerArgs
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-6.3-bin.zip
3. 修改JAVA_HOME,我的默认jdk是1.8,gradle插件要求11以上,所以需要在gradle.properties中配置jdk11的路径
gradle.properties中添加 org.gradle.java.home=/Users/macos/Tools/jdk-11.0.23.jdk/Contents/Home
完成以上配置,进入scrcpy路径,执行命令./gradlew assembleDebug
编译成功会在server/build/outputs/apk/debug/中生成apk文件