Android is an operating system all of us are aware of, even the majority of people are using Android smartphones and tablets. It is a Linux-based OS that is quite popular among the masses. Android is operated with a touch screen. Nowadays, Android technology has emerged to a great extent that it has replaced many other devices. It is the most used device for searching, finding information, buying or selling a product, paying bills, etc. There is nothing that you can’t do with an Android smartphone or tablet. And that’s the reason programmers and developers are working to design various applications to help Android users. You may encounter the error warning “using insecure protocols with repositories without explicit opt-in is unsupported Switch Maven repository in Android”.
You need to calm down when you face this error warning as it can be fixed. We are here to help you with valuable tips to get rid of the error warning. Go ahead with the post to figure out what you are really looking for. First, let’s check out how the error occurs
How the error pops up
When you try to update Android Studio, you land up in the error warning every time you execute the project code. This is what you get in return
A problem occurred configuring root project 'so10'.
> Could not resolve all dependencies for configuration ':classpath'.
> Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository
'maven3(http://oss.sonatype.org/content/repositories/snapshots)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols.
See https://docs.gradle.org/7.0.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
How To Solve the Error “using insecure protocols with repositories without explicit opt-in is unsupported Switch Maven repository in Android”
To resolve the error message, a Boolean allowInsecureProtocol needs to be specified as true to MavenArtifactRepository closure in Gradle 7+ version. With this, you can check if the way of communication with a repository using unsecured http is allowed or not. The below code will help you
repositories {
// maven { url "https://maven.fabric.io/public" }
maven {
url "https://jitpack.io"
}
maven {
url "https://raw.github.com/Raizlabs/maven-releases/master/releases"
}
maven {
url "http://oss.sonatype.org/content/repositories/snapshots"
allowInsecureProtocol = true //add this line
}
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://maven.google.com"
}
google()
mavenCentral()
jcenter()
}
It asked the user to consent when using protocols that are insecure only if it is required for security. On the other hand, Gradle doesn’t offer a global system or gradle property in order to allow the common disablement of this check.
It is a simple yet effective solution to help you remove the error.
Conclusion
We shed light on the simplest solution to fix the error warning “using insecure protocols with repositories without explicit opt-in is unsupported Switch Maven repository in Android”. It is the quickest way you can handle the exception.
I hope you find it helpful!