混淆签约的Andr​​oid APK? [英] Confused with signing android APK?

查看:172
本文介绍了混淆签约的Andr​​oid APK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照步骤按官员说,对数字签名我的Andr​​oid application.for签约在释放模式他们说使用的.keystore 文件和类似的这个的。我现在用的android工作室让我得到 .jks 文件instead.So我在哪里需要根据的 .jks 文件signing.html#释放模式相对=nofollow>文档建设我签署APK?请举一个简单的阐述上this.and说,如果我做错了什么?

I have followed the steps as per officials says for digitally signing my android application.for signing in release mode they are saying to use .keystore file and it's credentials like this.I am using android studio so that am getting .jks file instead.So where do i need to keep the .jks file according to the docs for building my signed APK ? Please give a simple elaboration on this.and say if am doing anything wrong ?

感谢。

推荐答案

您可以把 .jks 文件中的任何地方。
这意味着你可以把该文件的项目中,也可以将文件放在一个外部文件夹(只是看看下面的路径)。 这取决于你的政策。

You can put the .jks file anywhere.
It means that you can put the file inside your project, or you can put the file in an external folder (just take a look the path below). It depends by your policy.

只需使用摇篮来配置你的apk的签名。

Just use gradle to configure the signing of your apk.

android {

    signingConfigs {
        release
    }

    buildTypes {
            release {
                signingConfig signingConfigs.release
            }
    }
}

简单的方法:只是定义build.gradle文件中的凭证

Simple way: just define the credential inside your build.gradle file.

signingConfigs {
     release {
            //Pay attention to the path. You can use a relative path or an absolute path
            storeFile file("../your_key_store_file.jks")
            storePassword 'some_password'
            keyAlias 'alias_name'
            keyPassword 'key_password'

     }
  }

使用属性文件以保存凭证的脚本之外(例如,如果你不想推凭证的混帐回购协议)。

Using a .properties file to store the credentials outside the script (for example if you don't want to push the credential in a git repo).

例如: signing.properties

STORE_FILE=/path/to/your.keystore
STORE_PASSWORD=yourkeystorepass
KEY_ALIAS=projectkeyalias
KEY_PASSWORD=keyaliaspassword

然后让你的build.gradle文件中的这些值:

Then get these values in your build.gradle file:

signingConfigs {
        release
 }

然后定义:

def Properties props = new Properties()
def propFile = new File('signing.properties')
if (propFile.canRead()){
    props.load(new FileInputStream(propFile))

    if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
            props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
        android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
        android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
        android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
        android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
    } else {
        println 'signing.properties found but some entries are missing'
        android.buildTypes.release.signingConfig = null
    }
}else {
    println 'signing.properties not found'
    android.buildTypes.release.signingConfig = null
}

这篇关于混淆签约的Andr​​oid APK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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