1、在app下的build.gradle引用
apply from: "${rootProject.rootDir}/pgyer-upload.gradle"
并在android {...}里添加
android.applicationVariants.all { variant -> String taskSuffix = variant.name.capitalize() if (taskSuffix.contains("Release")) { task("pgyerBuild${taskSuffix}") { dependsOn ":app:assemble${taskSuffix}" group 'build' description 'Custom task for gradle' doLast { variant.outputs.all { output -> uploadApk(output.outputFile) } } } } }
2、pgyer-upload.gradle的下载地址:https://download.csdn.net/download/a2855090/15482928
3、打开pgyer-upload文件需要修改pgyer_apiKey蒲公英的apikey,机器人地址等
4、编译gradle完成后,在studio的右侧Tasks->build找到pgyerBuildRelease点击编译