Failed to read key from keystore解决方案

[java]  view plain copy
  1. Caused by: org.gradle.tooling.BuildException: Failed to read key from keystore  
  2.         at com.android.build.gradle.tasks.PackageApplication.doFullTaskAction(PackageApplication.groovy:110)  
  3.         at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.groovy:64)  
  4.         at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)  
  5.         at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactor  
  6. y.java:235)  
  7.         at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.jav  
  8. a:211)  
  9.         at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.  
  10. java:222)  
  11.         at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.jav  
  12. a:200)  
  13.         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)  
  14.         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)  
  15.         ... 47 more  
  16. Caused by: com.android.builder.packaging.SigningException: Failed to read key from keystore  
  17.         at com.android.builder.core.AndroidBuilder.packageApk(AndroidBuilder.java:1468)  
  18.         at com.android.builder.core.AndroidBuilder$packageApk$6.call(Unknown Source)  
  19.         at com.android.build.gradle.tasks.PackageApplication.doFullTaskAction(PackageApplication.groovy:95)  
  20.         ... 55 more  

build.gradle

[html]  view plain copy
  1. signingConfigs {  
  2.     robert {  
  3.         storePassword 'robert'  
  4.         storeFile file('/Users/bournewang/Documents/Project/android.keystore')  
  5.         keyPassword 'robert'  
  6.         keyAlias 'mike'  
  7.     }  

解决方案:

Check your keystore file for first, in you example you creating file with name my-release-key.keystore. If its correct and really present in folder Users/bournewang/Documents/Project check alias, in your example it is -alias alias_name, but in config you specified alias mike

大意是:

1.android.keystore可能不在指定目录下面

2.keyAlias不对


另:想知道真正原因的话,可以查看

[html]  view plain copy
  1. To find out what's wrong you can use gradle's singingReport command.  
  2.   
  3. On mac:  
  4.   
  5. ./gradlew signingReport  
  6. On Windows:  
  7.   
  8. gradle signingReport  

你可能感兴趣的:(android)