Gradle构建出现问题 - “找不到方法v2SigningEnabled,参数为[false]”

4

我最近更新了Android Studio,现在无法生成已签名的APK文件。
以下是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.me.myapp"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    signingConfigs {
        release {
            storeFile file("keystore.jks")
            storePassword "mypassword"
            keyAlias "My app"
            keyPassword "mypassword"
        }
    }
    buildTypes {
        release {
            v2SigningEnabled false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

这是我的错误:
INFO - e.project.sync.GradleSyncState - Sync with Gradle for project 'myApp' failed: Could not find method v2SigningEnabled() for arguments [false] on BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.

Consult IDE log for more details (Help | Show Log) 
2017-04-16 00:25:43,319 [ 554494]

你为什么添加了 v2SigningEnabled false - Jared Burrows
@JaredBurrows 我想使用旧的签名方法。 - Alex Jone
1个回答

2

SigningConfig不应该在buildTypes - Release中设置。应该像下面这样设置。

` android {

defaultConfig {
    applicationId "com.app.test"

}

signingConfigs {
    release {
        v2SigningEnabled false
    }
}
buildTypes {

        release {
            .....

        }
        debug {
            .....
        }


}

}`


如何在Intellij IDEA项目中使用v2SigningEnabled? - aida

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接