android-studioubuntuubuntu-22.04

Build Gradle failed when running android studio on ubuntu 22 from app launcher


I was installing Android Studio Koala | 2024.1.1.12 on Ubuntu 22.04.4 lts. When i open android studio from application launcher, build Gradle always failed producing this error:

Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-8.7-bin.zip'.
Reason: java.net.SocketTimeoutException: Read timed out

But when i open Android Studio using terminal like this:

sudo /opt/android-studio/bin/studio.sh

it works fine.

Here is the the jetbrains-studio.desktop generated by Android Studio -> Tools -> Create Desktop Entry:

Version=1.0
Type=Application
Name=Android Studio
Icon=/opt/android-studio/bin/studio.svg
Exec="/opt/android-studio/bin/studio.sh" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-studio
StartupNotify=true

I was trying to modify jetbrains-studio.desktop to run my own bash script that run Android Studio using sudo. But Gradle build still failed as before.

Modified jetbrains-studio.desktop:

Version=1.0
Type=Application
Name=Android Studio
Icon=/opt/android-studio/bin/studio.svg
Exec="/opt/android-studio/bin/sudo-studio.bash" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-studio
StartupNotify=true

/opt/android-studio/bin/sudo-studio.bash file:

#!/bin/bash

sudo /opt/android-studio/bin/studio.sh %f


Solution

  • My answer is supposed to be a comment but I can't comment currently due to reputation count. If you will run build command via terminal it will show more details about the error. Try running below command from the directory of your project, or from the integrated terminal of android studio.

    ./gradlew assembleDebug
    

    As a temporary solution I would recommend to move the android studio to your home directory (I mean "/home/"), to avoid any permission related issues.