- Check your Internet connection: Make sure you have an active internet connection and your internet is not restricted. You can try disabling any proxy settings or VPNs and see if that resolves the issue.
- Use a VPN: If you are behind a firewall or have restricted internet access, using a VPN (Virtual Private Network) can help you bypass these restrictions and access the necessary resources.
- Check CA-certs cache: In some cases, the issue may be caused by an outdated or corrupted CA-certs cache. You can try clearing the cache by running the following commands in a terminal:
- Disable Gradle's offline mode: If you have accidentally enabled Gradle's offline mode, it can prevent it from accessing the internet to download necessary dependencies. Make sure to disable this mode in the Gradle settings.
- Check your firewall settings: Ensure that your firewall is not blocking the necessary ports required for Gradle to access the internet. You can temporarily disable the firewall to see if that resolves the issue.
- Update Gradle and Kotlin versions: Make sure you are using the latest stable versions of Gradle and Kotlin. Sometimes, outdated versions can cause compatibility issues.
- Check for Proxy/VPN interference: If you are using a proxy or VPN, try disabling them temporarily to see if that resolves the issue. Some proxies or VPNs may interfere with Gradle's internet access.
- Clear Gradle cache: Sometimes, a corrupted Gradle cache can cause issues. Try clearing the cache by deleting the ".gradle" directory in your user home directory.
- Restart Android Studio: If you are using Android Studio, try restarting it. This can sometimes resolve temporary glitches or issues.
- Reinstall Gradle: If none of the above solutions work, you may need to reinstall Gradle. Make sure to follow the official documentation for your platform.
- Update Kotlin version in build.gradle: Ensure that the Kotlin version specified in your build.gradle file matches the version of the Kotlin plugin you are using. Sometimes, mismatched versions can cause issues.
- Check your proxy settings in Android Studio: If you are using Android Studio, ensure that the proxy settings are configured correctly. Go to "Settings > Appearance & Behavior > System Settings > HTTP Proxy" and check if the proxy settings are appropriate.
- Disable Charles Proxy: If you are using Charles Proxy for debugging network traffic, try disabling it temporarily to see if that resolves the issue. Charles Proxy can sometimes interfere with Gradle's internet access.
- Upgrade Kotlin plugin version: Update your Kotlin plugin version to the latest stable release in the build.gradle project file.
- Use the correct repository URL: Ensure that you are using the correct repository URL for the Kotlin plugin in your build.gradle file. The default repository URL is "https://plugins.gradle.org/m2/".
Code:
Check your Internet connection and make sure your Internet is not restricted.
Code:
I solved this problem by turning on proxy for all tunnels (not just HTTP) with a VPN app.
Code:
sudo su /usr/bin/printf '\xfe\xed\xfe\xed\x00\x00\x00\x02\x00\x00\x00\x00\xe2\x68\x6e\x45\xfb\x43\xdf\xa4\xd9\x92\xdd\x41\xce\xb6\xb2\x1c\x63\x30\xd7\x92' > /etc/ssl/certs/java/cacerts /var/lib/dpkg/info/ca-certificates-java.postinst configure
Code:
To disable it simply go to Settings > Build, Execution, Deployment > Build Tools > Gradle and deselect the "Offline work" checkbox.
Code:
plugins { id 'org.jetbrains.kotlin.jvm' version '1.8.21' apply false }
Code:
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false