เพิ่มหมายเลขเวอร์ชันต่อท้ายในโฟลเดอร์การแมป proguard

ฉันสามารถเปลี่ยนชื่อไฟล์ apk ของฉันใน gradle.build ได้โดยอัตโนมัติโดยใช้

setProperty("archivesBaseName", "MyAppName-$versionName")

มีวิธีที่คล้ายกันในการต่อท้ายชื่อโฟลเดอร์การแมป proguard ด้วยหมายเลขเวอร์ชันโดยอัตโนมัติหรือไม่

ปัจจุบันโฟลเดอร์มีค่าเริ่มต้นเป็น

...\app\build\outputs\mapping\release หรือ debug

ฉันสงสัยว่าเป็นไปได้หรือไม่ที่จะสร้างโฟลเดอร์การแมปเป็น release-1.0.1 หรือ debug-1.0.1


person Angel Koh    schedule 21.12.2016    source แหล่งที่มา
comment
ฉันรู้ว่าเราสามารถเปลี่ยนชื่อ APK โดยทางโปรแกรมตามคำถามของคุณ ขอบคุณ :)   -  person nishith kumar    schedule 21.12.2016
comment
หากคุณสามารถทำได้ จะมีการเขียนไว้ที่ไหนสักแห่งในเอกสารที่นี่: guardsquare.com/en /proguard/manual/usage#obfuscationoptions   -  person Blundell    schedule 30.12.2016


คำตอบ (2)


การติดตาม¹จะเปลี่ยนชื่อ mapping.txt เป็น mapping-release-1.0.1.txt ในโฟลเดอร์เดียวกัน

ในไฟล์โมดูล build.gradle:

android {
    // lots of gradle code

    // The following portion renames the mapping.txt file.
    applicationVariants.all { variant ->
        if (variant.getBuildType().isMinifyEnabled()) {
            variant.assemble.doLast {
                variant.mappingFile.renameTo(file(
                    "${variant.mappingFile.parent}/mapping-${variant.name}-${variant.versionName}.txt"))
            }
        }
    }
}

คุณสามารถใช้ variant.versionCode หรือตัวเลือกอื่นๆ ในชื่อไฟล์ได้

หวังว่านี่จะช่วยได้

person ozbek    schedule 30.12.2016

ฉันเดาว่าคุณสามารถเขียนวิธีการเปลี่ยนชื่อได้โดยการคัดลอกไฟล์ไปยังไดเร็กทอรีตามเวอร์ชันปัจจุบัน สิ่งที่คล้ายกับคำตอบที่นี่: วิธีเปลี่ยนชื่อไฟล์การแมป proguard ใน gradle สำหรับโปรเจ็กต์ Android

person Mina Wissa    schedule 30.12.2016