android studio 3.0 修改release生成的apk名稱


在網上找了很久,都無法使用,都報錯;然后使用bing搜索結果,pass掉幾個之后在一個博客上找到了對應的解決方案,經過測試還真行了,下面分享一下使用方法:

在android studio 3.0 的 Gradle Script 中打開 Module:app的 build.gradle,找到android 節點中的buildType節點,在buildType節點下添加代碼。

 

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.xxx.android.xxx"
        minSdkVersion 22
        targetSdkVersion 25
//        versionCode 1
//        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    //自動生成指定名稱的release發布版的 apk文件
    android.applicationVariants.all { variant ->
        def appName
        if (project.hasProperty("applicationName")){
            appName = applicationName
        }else{
            appName = parent.name
        }
        variant.outputs.all { output ->
            outputFileName = "你的release版apk的名稱.apk"
        }
    }
}

為了讓遇到困難的人看清,我把整個android節點的代碼都貼上來了。

再修改下,喝水不忘挖井人。國外此解決方案的博客連接:https://medium.com/@AndreSand/android-studio-3-0-fix-apk-naming-issue-when-updating-to-gradle-4-0-639da9d863cd

 

 

廣告:開發技術交流群:88390778

.NET技術交流與招聘


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM