网址大全
在Android上的应用
修改生成apk的路径和名字
Step1 在local.properties
中定义存放apk的文件夹路径
appReleaseDir=/Users/jady/StudioProjects/BiliFeed/app/src/main/assets
Step2 在module的build.gradle
中获取这个路径
在apply plugin: 'com.android.application'
后面添加这段代码
ext.appReleaseDir = ""
def loadProperties() {
def proFile = file("../local.properties")
Properties p = new Properties()
proFile.withInputStream { stream ->
p.load(stream)
}
appReleaseDir = p.appReleaseDir
}
loadProperties()
Step3 设置输出文件路径
android {
...
defaultConfig {
...
}
buildTypes {
...
}
applicationVariants.all { variant ->
variant.getPackageApplication().outputDirectory = new File(appReleaseDir)
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
outputFileName = "xxx.apk"
}
}
}
}
Step4 删除多余的output.json
在文件的最后面,加上这个任务
afterEvaluate {
assembleDebug.doLast {
delete appReleaseDir + '/output.json'
}
}