gradle.properties应该在gitignore中用于反应本机项目以隐藏发布密码吗?

时间:2017-02-08 14:08:03

标签: android react-native android-gradle gitignore

我正在开发Windows上的本机应用程序。为了generate a signed release apk我已将MYAPP_RELEASE_STORE_PASSWORD=***MYAPP_RELEASE_KEY_PASSWORD=***添加到我的/projectname/android/gradle.properties文件(Like it says so here)。现在我想知道是否应该将文件添加到gitignore以防止它被上传到github,或者是否有办法将密码存储在不同的文件中?

3 个答案:

答案 0 :(得分:3)

我在这里找到了将密码存储在单独文件中的解决方案:Sign APK without putting keystore info in build.gradle

在build.gradle中添加:

mysql> select 10 as number, "Checklist 10 Foo" as name, max(id), max(ts) as max_ts, callsign, max(time_hint_utc), count(*)
    -> from checklist_10
    -> union all
    -> select 11 as number, "Checklist 11 Bar" as name, max(id), max(ts) as max_ts, callsign, max(time_hint_utc), count(*)
    -> from checklist_11
    -> union all
    -> select 12 as number, "Checklist 12 Baz" as name, max(id), max(ts) as max_ts, callsign, max(time_hint_utc), count(*)
    -> from checklist_12
    -> 
    -> group by callsign, number
    -> order by max_ts;
+--------+------------------+---------+---------------+----------+---------------------+----------+
| number | name             | max(id) | max_ts        | callsign | max(time_hint_utc)  | count(*) |
+--------+------------------+---------+---------------+----------+---------------------+----------+
|     10 | Checklist 10 Foo |       2 | 1486554484635 | VRTEST   | 2017-02-08 12:21:32 |        2 |
|     11 | Checklist 11 Bar |       2 | 1486554490674 | VRTEST   | 2017-02-08 12:21:39 |        2 |
|     12 | Checklist 12 Baz |       2 | 1486554496378 | VRTEST   | 2017-02-08 12:21:44 |        2 |
|     12 | Checklist 12 Baz |       3 | 1486554496379 | VRTEST2  | 2017-02-08 12:21:45 |        1 |
+--------+------------------+---------+---------------+----------+---------------------+----------+
4 rows in set (0.00 sec)

再往下一点:

// Load keystore
def keystorePropertiesFile = rootProject.file("keystores/release.keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

然后将signingConfigs { release { storeFile file(keystoreProperties['MYAPP_RELEASE_STORE_FILE']) storePassword keystoreProperties['MYAPP_RELEASE_STORE_PASSWORD'] keyAlias keystoreProperties['MYAPP_RELEASE_KEY_ALIAS'] keyPassword keystoreProperties['MYAPP_RELEASE_KEY_PASSWORD'] } } 添加到release.keystore.properties文件中。

(很抱歉回答我自己的问题,我讨厌这样做..)

答案 1 :(得分:0)

您可以将该信息添加到ChangeDetectorRef上的super gradle.properties文件中,它应该随时为您准备。

您还可以在${HOME}/.gradle/gradle.properties上重命名这些属性,并根据需要为不同的项目使用不同的属性。

例如,我的项目FOO

app/build.gradle

112 release { 113 storeFile file(FOO_RELEASE_STORE_FILE) 114 storePassword FOO_RELEASE_STORE_PASSWORD 115 keyAlias FOO_RELEASE_KEY_ALIAS 116 keyPassword FOO_RELEASE_KEY_PASSWORD 117 } 我有:

${HOME}/.gradle/gradle.properties

答案 2 :(得分:0)

您可以创建${HOME}/.gradle/gradle.properties,因为默认情况下它不存在,至少在Windows上如此。

将密钥完全放在项目gradle.properties中。您可以看到优先级here