Android的摇篮Studio中的属性文件签署 [英] Gradle Android Studio signing with a properties file

查看:708
本文介绍了Android的摇篮Studio中的属性文件签署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试签下我与gradle这个build文件的应用程序。当我使用它的工作原理平原signingConfigs(signingConfigs.release)!但如果我正尝试从读出的属性的属性,文件,它不会致使工作。 (signingConfigs.config)

I´m trying to sign my app with the gradle build file. When I use the plain signingConfigs it works (signingConfigs.release)! But If I´m trying to read the properties from the properties-file it won´t work. (signingConfigs.config)

Properties props = new Properties();
props.load(new FileInputStream(file(rootProject.file("signing.properties"))))

android {
        signingConfigs {
            config {
                storeFile file(props["storeFile"])
                storePassword props["storePassword"]
                keyAlias props["keyAlias"]
                keyPassword props["KeyPassword"]
            }
            release {
                storeFile file("..\\xyz.jks")
                storePassword "****"
                keyAlias "****"
                keyPassword "****"
            }
        } 
    .
    .
    .
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                signingConfig signingConfigs.release
            }
            debug {
                applicationIdSuffix '.debug'
                versionNameSuffix '-SNAPSHOT'
            }
        }

属性文件:

storeFile=xyz.jks
storePassword=xyz
keyAlias=xyz
keyPassword=xyz

当我运行该项目,机器人工作室显示一个对话框,说:

When I run the project, android studios show a dialog which says:

xyz.apk未签名。请配置的签名信息
  选定的味道使用项目结构对话框。

xyz.apk is not signed. Please configure the signing information for the selected flavor using the Project Structure dialog.

属性文件被正确读取,因为我可以从日志文件的一些属性扔控制台。

The property file is read correctly because I can log some properties from the file throw the console.

我的一些系统的详细信息:

Some of my system details:

Android的工作室0.8.6
Windows 8.1中的x64
1.12的gradle

Android Studio 0.8.6 Windows 8.1 x64 gradle 1.12

希望有人能帮助我。如果你想了解更多详细信息,然后问我。

Hope anyone can help me. If you want to know more details, then ask me.

推荐答案

这是我做的,它为我的作品:

This is what I do and it works for me:

signingConfigs {
    release {
        def Properties localProps = new Properties()
        localProps.load(new FileInputStream(file('../local.properties')))
        def Properties keyProps = new Properties()
        assert localProps['keystore.props.file'];
        keyProps.load(new FileInputStream(file(localProps['keystore.props.file'])))
        storeFile file(keyProps["store"])
        keyAlias keyProps["alias"]
        storePassword keyProps["storePass"]
        keyPassword keyProps["pass"]
    }
}

我local.properties文件包含到一个keystore.properties文件的路径。它包含了我对密钥库信息:

My local.properties file contains a path to a "keystore.properties" file. That contains my info about the keystore:

store=***
alias=***
pass=***
storePass=***

也许是两个临preties文件的加载是多余的,但它确实为我工作。

Perhaps the loading of two Propreties file is redundant, but it does work for me.

这篇关于Android的摇篮Studio中的属性文件签署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆