Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Failed to create keystore

I'm trying to run my app from inside Android Studio, but every time I try i get this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:validateSigningDebug'.
> java.util.concurrent.ExecutionException: 
com.android.builder.utils.SynchronizedFile$ActionExecutionException: 
com.android.ide.common.signing.KeytoolException: Failed to create 
keystore.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

Searching for a solution online did not lead me to a suitable one. Running it with the --debug option gives me this result:

15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':android:validateSigningDebug'.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 2s

The OS I'm using is Archlinux and the permissions for the .android folder are:

$ ls -la
drwxr-xr-x  4 speedking speedking    4096 15 nov 11.59 .android

Can anyone help me please?

Edit: Building a signed apk does work, just running the app from Android Studio doesn't.

Running it with --stacktrace outputs this:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:validateSigningDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':android:validateSigningDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.internal.UncheckedException: java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:63)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:76)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:731)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:705)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.builder.utils.SynchronizedFile.doActionWithMultiProcessLocking(SynchronizedFile.java:267)
at com.android.builder.utils.SynchronizedFile.write(SynchronizedFile.java:232)
at com.android.builder.utils.SynchronizedFile.createIfAbsent(SynchronizedFile.java:328)
at com.android.build.gradle.internal.tasks.ValidateSigningTask.validate(ValidateSigningTask.java:90)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
... 39 more
Caused by: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.builder.utils.SynchronizedFile.lambda$createIfAbsent$0(SynchronizedFile.java:336)
at com.android.builder.utils.SynchronizedFile.doActionWithMultiProcessLocking(SynchronizedFile.java:265)
... 43 more
Caused by: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.ide.common.signing.KeystoreHelper.createNewStore(KeystoreHelper.java:158)
at com.android.ide.common.signing.KeystoreHelper.createDebugStore(KeystoreHelper.java:105)
at com.android.build.gradle.internal.tasks.ValidateSigningTask.lambda$validate$0(ValidateSigningTask.java:111)
at com.android.builder.utils.SynchronizedFile.lambda$createIfAbsent$0(SynchronizedFile.java:334)
... 44 more
Caused by: java.lang.SecurityException: class "org.bouncycastle.jcajce.provider.symmetric.IDEA$Mappings"'s signer information does not match signer information of other classes in the same package
at org.bouncycastle.jce.provider.BouncyCastleProvider.loadAlgorithms(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.setup(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.access$000(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider$1.run(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(Unknown Source)
at com.android.ide.common.signing.KeystoreHelper.generateKeyAndCertificate(KeystoreHelper.java:254)
at com.android.ide.common.signing.KeystoreHelper.createNewStore(KeystoreHelper.java:143)
... 47 more


* Get more help at https://help.gradle.org

BUILD FAILED in 1s
like image 450
NicoNex Avatar asked Nov 15 '17 14:11

NicoNex


People also ask

What is keystore in Android Studio?

The Android Keystore system lets you store cryptographic keys in a container to make them more difficult to extract from the device. Once keys are in the keystore, you can use them for cryptographic operations, with the key material remaining non-exportable.

Where to store encryption key in Android?

The Android Keystore system lets you store cryptographic keys in a container to make it more difficult to extract from the device. Once keys are in the keystore, they can be used for cryptographic operations with the key material remaining non-exportable.

Why keystore file is used?

As a security measure, Android requires that apps be signed in order to be installed. Signing an app first requires creating keystores. A keystore is a storage mechanism for security certificates. A public key certificate is used to sign an APK before deployment to services like the Google Play Store.

Is Android keystore secure?

The Android Keystore provides APIs to perform cryptographic operations within this trusted environment and receive the result. It was introduced in API 18 (Android 4.3). A strongbox backed Android Keystore is currently the most secure and recommended type of keystore.


1 Answers

It turned out I didn't have a debug keystore. A debug keystore is used to sign Android apps during development, to generate it I just typed this command in the terminal:

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

as stated in this guide: https://coderwall.com/p/r09hoq/android-generate-release-debug-keystores

like image 165
NicoNex Avatar answered Sep 27 '22 19:09

NicoNex