Environment variable in settings.gradle not working with Android Studio

后端 未结 6 1035
长发绾君心
长发绾君心 2020-12-17 15:37

I do have a multi-module project with a library project in a different root path. As illustration you can imagine something like this:

/projects_home/project         


        
6条回答
  •  醉酒成梦
    2020-12-17 16:30

    Android Studio does read the environment variables. You can prove it by launching Android Studio from the shell in which those env. variables being specified instead of from X-window dash board.

    The reason you did not have those variables is the X-window environment you were using did not read $HOME/.bashrc which contained those variables. This makes sense because bashrc is for Bash not X.

    Assuming you are using GNOME or Unity, to launch Android Studio with those environment variables being specified, just modify the .desktop file of Android Studio (e.g. ~/.local/share/applications/android-studio.desktop):

    Find this line:

    Exec="/home/username/tools/android/android-studio/bin/studio.sh" %f
    

    Change it to:

    Exec=env LIB_ROOT=/libraries_home "/home/username/tools/android/android-studio/bin/studio.sh" %f
    

    Note:

    This modification just prepend env LIB_ROOT=/libraries_home to the original command. You must replace username with your own user name.

    Update

    If you have any questions, please leave a comment instead of editing the answer directly.

提交回复
热议问题