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

1

8

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.

Bettinabettine answered 2/2, 2019 at 9:51 Comment(0)
E
15

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

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

Expressionism answered 2/2, 2019 at 9:58 Comment(2)
Generally I don't think running apps as root is a good idea though.Expressionism
Yes sir. Your solution worked for me. I'll accept this as the right solution in a few minutes. And about your advise, yes I know I shoudn't run as root user but due to some permission issues I had to be root for a certain project. Thank you so muchBettinabettine

© 2022 - 2024 — McMap. All rights reserved.