我想让Jenkins服务器构建我的基于Cordova的(Android)应用程序。为此,我打算使用Gradle(因为来自Cordova的项目具有所有必需的文件)。我从IntelliJ -> Export signed APK
多次发布了该应用程序,但我无法通过我的密钥库正确签署gradle'd版本。
这是我配置的内容:
通过keytool
生成,已用于通过Google Play商店发布我的应用。我以为Gradle可能在密钥库和/或密钥密码中遇到特殊字符问题,所以我使用了
keytool -storepasswd -keystore mykeystore.keystore
和
keytool -keypasswd -alias myalias -keystore mykeystore.keystore
改变它们。我100%确定我的Gradle配置文件中的密码是正确的。
这个文件是为项目预先生成的,我的变化不大。我没有触及以下几行:
if (cdvReleaseSigningPropertiesFile) {
signingConfigs {
release {
// These must be set or Gradle will complain (even if they are overridden).
keyAlias = ""
keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
storeFile = null
storePassword = "__unset"
}
}
(snip)
}
为了满足cdvReleaseSigningPropertiesFile
条件,我在项目android目录中创建了一个文件release-signing.properties
(参见http://cordova.apache.org/docs/en/dev/guide/platforms/android/index.html#setting-gradle-properties)。
storeFile=keystore/mykeystore.keystore
storePassword="my_password"
keyAlias="myalias"
keyPassword="my_password"
现在,当我运行./gradlew signingReport --info
时,我得到以下输出:
Selected primary task 'signingReport' from project :
Tasks to be executed: [task ':signingReport', task ':CordovaLib:signingReport']
:signingReport (Thread[main,5,main]) started.
:signingReport
Executing task ':signingReport' (up-to-date check took 0.001 secs) due to:
Task has not declared any outputs.
Variant: debugAndroidTest
Config: debug
Store: /Users/myusername/.android/debug.keystore
Alias: AndroidDebugKey
MD5: (snip)
SHA1: (snip)
Valid until: Mittwoch, 3. Dezember 2042
----------
Variant: releaseUnitTest
Config: release
Store: /Users/myusername/Documents/MyApplication/project/platforms/android/keystore/mykeystore.keystore
Alias: "myalias"
Error: Failed to read key "myalias" from store "/Users/myusername/Documents/MyApplication/project/platforms/android/keystore/mykeystore.keystore": Keystore was tampered with, or password was incorrect
----------
Variant: release
Config: release
Store: /Users/myusername/Documents/MyApplication/project/platforms/android/keystore/mykeystore.keystore
Alias: "myalias"
Error: Failed to read key "myalias" from store "/Users/myusername/Documents/MyApplication/project/platforms/android/keystore/mykeystore.keystore": Keystore was tampered with, or password was incorrect
----------
Variant: debug
Config: debug
Store: /Users/myusername/.android/debug.keystore
Alias: AndroidDebugKey
MD5: (snip)
SHA1: (snip)
Valid until: Mittwoch, 3. Dezember 2042
----------
Variant: debugUnitTest
Config: debug
Store: /Users/myusername/.android/debug.keystore
Alias: AndroidDebugKey
MD5: (snip)
SHA1: (snip)
Valid until: Mittwoch, 3. Dezember 2042
----------
:signingReport (Thread[main,5,main]) completed. Took 0.292 secs.
:CordovaLib:signingReport (Thread[main,5,main]) started.
:CordovaLib:signingReport
Executing task ':CordovaLib:signingReport' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
Variant: debugAndroidTest
Config: debug
Store: /Users/myusername/.android/debug.keystore
Alias: AndroidDebugKey
MD5: (snip)
SHA1: (snip)
Valid until: Mittwoch, 3. Dezember 2042
----------
Variant: release
Config: none
----------
Variant: debug
Config: debug
Store: /Users/myusername/.android/debug.keystore
Alias: AndroidDebugKey
MD5: (snip)
SHA1: (snip)
Valid until: Mittwoch, 3. Dezember 2042
----------
Variant: releaseUnitTest
Config: none
----------
Variant: debugUnitTest
Config: debug
Store: /Users/myusername/.android/debug.keystore
Alias: AndroidDebugKey
MD5: (snip)
SHA1: (snip)
Valid until: Mittwoch, 3. Dezember 2042
----------
:CordovaLib:signingReport (Thread[main,5,main]) completed. Took 0.008 secs.
BUILD SUCCESSFUL
Total time: 23.152 secs
Stopped 0 compiler daemon(s).
运行./gradlew build
会产生以下错误消息:
:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:validateReleaseSigning
:packageRelease FAILED
失败:构建因异常而失败。
- 出了什么问题: 任务':packageRelease'的执行失败。 无法从商店“/ Users / myusername / Documents”中读取密钥“myalias” /所有MyApplication /项目/平台/安卓/密钥库 /mykeystore.keystore“:密钥库被篡改,或密码不正确
有关如何解决该错误的任何想法?
答案 0 :(得分:0)
由于我无法找到Gradle如此顽固的原因,我删除了文件release-signing.properties
以让Gradle构建 unsigned APK并使用以下命令对shell脚本中的文件:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore mykeystore.keystore
myapplication.apk mykeyalias -storepass mypassword
/path/to/somewhere/android-sdk-macosx/build-tools/23.0.3/zipalign -v 4
myapplication.apk myapplication-signed.apk