Search code examples
androidandroid-studioubuntuandroid-keystore

How to change the debug.keystore location in Android Studio?


I am using Ubuntu for Android Development. I launch Android Studio as a root user every time. So my SDK files are all located at /root/Android/Sdk.

I also have my debug.keystore file located at

/root/.android/debug.keystore

But whenever I run my app the following error shows up

/home/USERNAME/.android/debug.keystore (No such file or directory)

Looks like Android Studio is looking for the debug.keystore inside /home/USERNAME/.android/debug.keystore instead of /root/.android/debug.keystore and hence the error.

How could I change this and force Android Studio to look for the debug.keystore file in my /root/.android directory?

One solution I thought of was to launch Android Studio as a local user (non-root user), so that everything fits up. But that'll have two installations of Android Studio on my system (one as root and one as local user) and I don't want that.

Any help would be appreciated. Thank you.


Solution

  • You can specify the keystore location in your app's build.gradle file like:

    android {
        signingConfigs {
            debug {
                storeFile file("/root/.android/debug.keystore")
            }
        }
    }