android - 错误 :(81, 0) 不再支持 getMainOutputFile。如果需要确定输出的文件名,请使用 getOutputFileName。

标签 android android-studio-3.0

我正在尝试使用以下代码自定义构建过程

   android.applicationVariants.all { variant ->
            def appName = "MyApplication.apk"

            variant.outputs.each { output ->
                output.outputFile = new File(output.outputFile.parent, appName)
            }
        }

但是从 android studio 3.0 它不工作我得到低于错误

错误:(81, 0) 不再支持 getMainOutputFile。如果需要确定输出的文件名,请使用 getOutputFileName。

最佳答案

就这样吧:

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig getSigningConfig()
        android.applicationVariants.all { variant ->
            def date = new Date();
            def formattedDate = date.format('dd MMMM yyyy')
            variant.outputs.all {
                def newApkName
                newApkName = "MyApp-${variant.versionName}, ${formattedDate}.apk"
                outputFileName = newApkName;
            }
        }
    }
}

关于android - 错误 :(81, 0) 不再支持 getMainOutputFile。如果需要确定输出的文件名,请使用 getOutputFileName。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44516023/

相关文章:

Android - EditText 在使用 textAllCaps 时给出 IndexOutOfBounds 异常

android - 为什么我们必须重建应用程序才能看到设备的一些变化?

android - 单击抽屉导航后新 Activity 不会启动

Android WebView 请求焦点 : How to prevent scrolling to top?

java - AutoCompleteTextView 文本过滤

安卓工作室 : No target device found: Why?

java - 检测两个物体之间的碰撞并使碰撞点增加

android - 变体调试没有类型为 INSTANT_RUN_MERGED_MANIFESTS 的输出

android - Device-File-Explorer在Android-Studio中的作用是什么

android - 三星 Galaxy S4 屏幕尺寸