在網上找了很久,都無法使用,都報錯;然后使用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