21

I'm a newbie to programming in Android, and I just tried to run my build and got this message

Execution failed for task ':app:validateDebugSigning'.
> Unable to recreate missing debug keystore.

What does this mean? I'm using Android Studio.

Brandroid
  • 266
  • 1
  • 2
  • 10
  • Check your /.android directory. You should have a debug.keystore or some other key for signing builds. At least, Eclipse works this way. Make sure this directory is not locked down and is accessible by the program you are using. – Nabren Jan 28 '14 at 21:51
  • 1
    I solved this problem on Windows 7 just setting in the variables environment of windows 7: ANDROID_SDK_HOME to C:\Users\guillermo\.android\ (where guillermo is my windows username) – gtamborero Jul 27 '15 at 15:54
  • Also be sure to not be write a protected directory (the whole \.android). Remember as well to reboot windows every time you change the environment variables!! – gtamborero Jul 27 '15 at 16:47

3 Answers3

30

I just resolved this same problem, the permissions on my ~/.android folder were wrong.

Specifically, Android Studio needs to be able to write to that folder. By default, my installation created that directory as owned by root, and only writable by root. This was a problem because Android Studio was running as me, and thus did not have permissions to write there.

You can confirm this by executing these commands in Terminal.app (or whatever terminal app you run):

You'll probably see permissions like this:

> cd ~
> ls -la
...cut...
drwxr-xr-x    7 root  andyo      238 Mar 31 14:00 .android
...cut...

The problem is that, since root owns the directory and the permissions are set as 755, then the non-root user cannot write to the directory.

To fix this, just change the ownership of the directory to be yourself (there shouldn't be any root owned directories in your home directory anyway).

> sudo chown -R andyo .android
> ls -la
...cut...
drwxr-xr-x    7 andyo  andyo      238 Mar 31 14:00 .android
...cut...
Andy Obusek
  • 12,614
  • 4
  • 41
  • 62
  • Didnt fix the error in my case. Perhaps that's not the location of the debug.keystore file? Do you know where I can check this? – Chris Apr 01 '15 at 20:47
  • What does the tilde represent before your Android folder? Presumably you are a predominant Linux user? – Andrew S May 27 '15 at 01:13
  • It means the current user's home directory http://superuser.com/questions/211355/what-does-the-mean-in-a-file-path – Andy Obusek May 27 '15 at 12:01
0

May be it's because the new "instant-run" feature. My write-permissons for the .android folder where ok. But for me it worked only after i deleted the hole ".android" folder then i had to CREATE A NEW EMULATOR, and only after that there was a new debug.keystore

cabanni
  • 349
  • 5
  • 12
0

Running the IDE as Administrator did a trick for me. It was a permissions issue on my computer. Just left it here if somebody need.

  • Where I think this is "going down the wrong rabbit hole". You shouldnt need to run a dev IDE as "root" to get it working. – GhostCat Oct 09 '17 at 13:59
  • Why? ----------- – user3575956 Oct 09 '17 at 14:32
  • 1
    Generally speaking: bad practice. "root" has access to **all** things in your system. You want to absolutely minimize the things that require "root" permission. In other words: you rather strive to fix incorrect permissions of a directoy, instead of running a whole application as "root". – GhostCat Oct 09 '17 at 14:49