试图在android studio中生成签名的apk会出错

时间:2015-04-02 08:00:01

标签: android

我想在我的项目的android studio中生成签名的apk但是它给了我错误。我是android的新手,请帮助我。

Gradle控制台提供如下堆栈跟踪:

Executing tasks: [:app:assembleRelease]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:compileReleaseJava UP-TO-DATE
:app:lintVitalRelease
:app:compileReleaseNdk UP-TO-DATE
:app:preDexRelease UP-TO-DATE
:app:dexRelease UP-TO-DATE
:app:processReleaseJavaRes UP-TO-DATE
:app:validateExternalOverrideSigning
:app:packageRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:packageRelease'.
> File '2222' specified for property 'signingConfig.storeFile' does not exist.

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

BUILD FAILED

Total time: 3.685 secs

同时控制台消息gradle:

Information:Gradle tasks [:app:assembleRelease]
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:compileReleaseJava UP-TO-DATE
:app:lintVitalRelease
:app:compileReleaseNdk UP-TO-DATE
:app:preDexRelease UP-TO-DATE
:app:dexRelease UP-TO-DATE
:app:processReleaseJavaRes UP-TO-DATE
:app:validateExternalOverrideSigning
:app:packageRelease FAILED
Error:A problem was found with the configuration of task ':app:packageRelease'.
> File '2222' specified for property 'signingConfig.storeFile' does not exist.
Information:BUILD FAILED
Information:Total time: 3.685 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

我的Gradle文件是这样的:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.mubashirgul.androidtest"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

            debug {

            }

    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
}

1 个答案:

答案 0 :(得分:1)

我正是这样做的:

的build.gradle:

apply plugin: 'com.android.application'

android {
.
.
.

signingConfigs {
    release
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles 'proguard.pro'
        debuggable false
        signingConfig signingConfigs.release
    }
.
.
.
}

dependencies {
    ...
}

def props = new Properties()

props.load(new FileInputStream(rootProject.file("keystore.properties")))
android.signingConfigs.release.storeFile rootProject.file(props.keyStore)
android.signingConfigs.release.storePassword props.keyStorePassword
android.signingConfigs.release.keyAlias props.keyAlias
android.signingConfigs.release.keyPassword props.keyAliasPassword

keystore.properties:

keyStore=manamana.keystore_filname
keyStorePassword=manamana_password
keyAlias=manamana_alias
keyAliasPassword=manamana_alias_password

然后我在项目的根目录中拥有密钥库,并将“keystore.properties”添加到.gitignore并且从未签入