Android Studio 2.2 - Can no longer create unsigned

2019-09-12 04:29发布

问题:

After upgrading to Android Studio 2.2, I can no longer create an unsigned release build. Debug builds are created fine. This problem didn't happen on Android Studio 2.1. I can't figure it out. The app gradle file has this:

defaultConfig {
    applicationId "com.company.myapp"
    versionCode 66
    versionName "1.0"
    signingConfig signingConfigs.noSigning
    minSdkVersion 15
    targetSdkVersion 23
    multiDexEnabled true
}
buildTypes {
   debug {
   }

   release {
       minifyEnabled true // Set to true to enable proguard
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
       signingConfig signingConfigs.noSigning
       zipAlignEnabled false
   }

   releaseLive.initWith(buildTypes.release);

   releaseLive {
       signingConfig signingConfigs.noSigning
   }
}

This is what happens when the gradle task 'assembleRelease' or 'assembleReleaseLive' is run, then I press the "text mode" button on the 'Run' window to get the text output:

Executing external task 'assembleReleaseLive'...
:app:preBuild UP-TO-DATE
...
[All tasks run successfully up to until this]
...
:app:lintVitalReleaseLive
:app:validateSigningReleaseLive FAILED
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:validateSigningReleaseLive'.
> Keystore file not set for signing config noSigning

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Does anyone know how to solve this? If I remove the "signingConfig" lines, it does not fix it.

回答1:

I eventually figured it out: Remove all 3 lines of "signingConfig signingConfigs.noSigning", where "noSigning" was defined as:

signingConfigs {
    noSigning {
        keyAlias ''
        keyPassword ''
        storePassword ''
        storeFile null
    }
    defaultSigning {
        storeFile file('signing/signing.keystore')
        storePassword 'password'
        keyAlias 'alias'
        keyPassword 'password'
    }
}

Those "noSigning" lines do not seem to work on Android Studio 2.2. I guess they are non-standard anyway, because the 'assembleRelease' task will create an unsigned build by default anyway.