每当我在Android Studio中生成一个已签名的apk时,默认情况下它会将名称命名为app-release.apk ...
我们可以进行任何设置,以便它应该提示并询问我需要分配给apk的名称(在eclipse中的方式)
我所做的是 - 生成后重命名apk.这不会给出任何错误但是有任何真正的方法,以便我可以在设置中进行任何更改以获得提示.
注意::
生成apk安卓工作室给我一个选择位置的提示(仅)
我正在用gradle构建一个Android应用程序.到目前为止,我使用Manifest文件来增加versionCode,但是我想从外部文件中读取versionCode,并且取决于它是发布风格还是调试风格增加了versionCode.我尝试了额外的属性,但是你无法保存它们,这意味着下次我构建它时我得到了相同的版本代码.任何帮助将非常感谢!
project.ext{
devVersionCode = 13
releaseVersionCode = 1
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile project(':Cropper')
compile "com.android.support:appcompat-v7:18.0.+"
compile "com.android.support:support-v4:18.0.+"
compile fileTree(dir: 'libs', include: '*.jar')
}
def getReleaseVersionCode() {
def version = project.releaseVersionCode + 1
project.releaseVersionCode = version
println sprintf("Returning version %d", version)
return version
}
def getDevVersionCode() {
def version = project.devVersionCode + 1
project.devVersionCode = version
println sprintf("Returning version %d", version)
return …Run Code Online (Sandbox Code Playgroud) 我从一个回答我的一个问题的人那里收到了一行代码,但我很困惑:"&&"在这个批处理文件中做了什么.
@echo off
set /p Quest="How are you today? "
echo %Quest% > Results.txt
findstr /r /i "not.*good not.*well" Results.txt >nul && echo Sorry && goto pause
findstr /i "good well" Results.txt >nul && echo My day is doing good as well
:pause
pause
Run Code Online (Sandbox Code Playgroud) 我正在尝试以.aab格式重命名生成的文件<appname>-<variant>-<buildType>-<version>,有什么方法可以重命名输出包文件,类似于 apk 重命名。
复制和重命名我试过了,但问题是我需要将包命名为<appname>-<variant>-<buildType>-<version>. 当我创建这里提到的任务时如何使用 Gradle 更改为 App Bundles 生成的文件名?
获取变体是使用一个子字符串,它同时给出variantBuildtype.
我在 Gradle 中输入了以下代码。
///start
applicationVariants.all { variant ->
variant.outputs.each { output ->
println("Roop: mappingFile: ${output.outputFile}")
}
variant.assemble.doLast {
// doLast {
File dir = new File("${project.projectDir}/out1")
dir.mkdirs()
println("Roop: copy")
variant.outputs.each { output ->
File file = output.outputFile
println("Roop: file:" + file)
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我从 android studio 执行 Build Apk 时,在创建 apk后会执行 Variant.assemble.doLast 。但是如果我执行Build Bundle ,则不会调用相同的 doLast 。
为什么没有为 BuildBundle 调用 doLast 的任何信息?
在构建APK时,我可以在build.gradle脚本中更改APK名称,如下所示:
android.applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
variant.outputs.all {
outputFileName = "${variant.applicationId}-v${variant.versionName}-${variant.name}.apk"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我会有这样的东西 com.myapp.package-v1.x.x-release
有没有办法与Android App Bundles做类似的事情,总是不方便 app.aab
我用下面的build.gradle生成的apk文件,其结果将是的放大镜-V1.01-自由release.apk为免费版 的放大镜-V1.01-PRO-release.apk的亲版。-free-release或-pro-release由Android Studio 3.4.2自动作为后缀添加到文件名中。
我尝试使用相同的build.gradle产生.aab文件,我发现结果的放大镜-V1.01的免费和 的放大镜-V1.01为亲,有相同的,为什么呢? Android Studio 3.4.2不会自动将-free-release或-pro-release作为后缀添加到文件名中。
新增内容:
就像Image 1一样,我使用Android Studio生成了不同版本的.apk和.aab 。
build.gradle
android {
compileSdkVersion 28
flavorDimensions "default"
defaultConfig {
applicationId "info.dodata.magnifyingglass"
minSdkVersion 21
targetSdkVersion 28
versionCode 2
versionName "1.02"
archivesBaseName = "MagnifyingGlass-V" + versionName
}
productFlavors {
free {
applicationId "info.dodata.magnifyingglass"
}
pro {
applicationId "info.dodata.magnifyingglass.pro"
}
}
buildTypes {
release { …Run Code Online (Sandbox Code Playgroud)