Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Android Studio be run with sudo on Linux

I am facing issues when I need to, for example, download new Build-tools using the Standalone SDK Manager. It says it does not have permissions etc - so I run ./studio.sh with sudo, which fixes the problem.

I have not faced more problems yet, but what is the right way of running Android Studio on Linux - with, or without sudo rights? I do not want grant it rights if it can do without it.

Just to mention, Android Studio is placed at /opt/android-studio/... And the SDK at ~/Android/Sdk/... (to my understanding this should not need root privileges?)

UPDATE
I keep getting access errors if running without sudo and simply trying to build the project.

Could not read path '/home/fakepath/app/build/intermediates/exploded-aar/com.google.maps.android/android-maps-utils/0.4.4/jni'

like image 277
Morphing Coffee Avatar asked Nov 16 '16 02:11

Morphing Coffee


Video Answer


2 Answers

I found the best solution so far the worked for me is a constructive answer:

  • sudo for Android Studio?

    It's usually good to minimize the programs you need to run as root. - @Kyle

    Run Android Studio without sudo

  • sudo for SDK Manager only

    You can run just the SDK manager by running the shell script "android" in the android-sdk/tools folder sudo sh /opt/android-sdk/tools/android - @Kyle

    Launch SDK Manager separately when an update is needed

  • Granting file access permissions

    if you wanted to run it as your own user, you could do that by changing ownership of the entire /opt/android-studio directory (recursively) - @matias elgart

    sudo chown -R youruser:youruser /home/fakepath/app - @num8er

    So in my case, I have changed the ownership of Android SDK folder for Android Studio to pick up the files without any problems. This has solved my issues:

    sudo chown -R myusername:myusername ~/fakepath/Android/Sdk/
    
like image 190
Morphing Coffee Avatar answered Sep 22 '22 15:09

Morphing Coffee


It's usually good to minimize the programs you need to run as root. You can run just the SDK manager by running the shell script "android" in the android-sdk/tools folder

$ sh /opt/android-sdk/tools/android
like image 40
Kyle Avatar answered Sep 19 '22 15:09

Kyle