Gradle sync fails every time whenever I open android studio. here is my gradle.build files. Can someone please tell me how to fix this issue? I have gradle 7.2 installed. But I can't figure out what is causing this issue.. I even tried allowInsecureProtocol = true
gradle.build/android
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
googlePlayServicesAuthVersion="16.0.1"
}
repositories {
google()
mavenCentral(){
allowInsecureProtocol = true
}
maven{
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.google.gms:google-services:4.3.3'
classpath("com.android.tools.build:gradle:4.2.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral(){
allowInsecureProtocol = true
}
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
mavenCentral(){
allowInsecureProtocol = true
}
maven { url 'https://www.jitpack.io' }
}
}
gradle.build/app
buildscript {
repositories {
google()
mavenCentral(){
allowInsecureProtocol = true
}
maven { url "https://plugins.gradle.org/m2/" }
maven { url "http://repo1.maven.org/maven2" }
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2'
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
mavenCentral()
google()
mavenCentral(){
allowInsecureProtocol = true
}
}
}
apply plugin: 'com.android.library'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// Use either AndroidX library names or old/support library names based on major version of support lib
def supportLibVersion = safeExtGet('supportLibVersion', '27.1.1')
def supportLibMajorVersion = supportLibVersion.split('\\.')[0] as int
def appCompatLibName = (supportLibMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation "$appCompatLibName:$supportLibVersion"
implementation 'com.facebook.react:react-native:+'
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '21.1.0')}"
}
This is the error I get
A problem occurred configuring root project 'RentInCars'.
> Could not resolve all dependencies for configuration ':classpath'.
> Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'BintrayJCenter2(http://jcenter.bintray.com/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'RentInCars'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.lambda$run$0(LifecycleProjectEvaluator.java:102)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$0(DefaultProjectStateRegistry.java:325)
org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
Caused by: org.gradle.api.InvalidUserCodeException: Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'BintrayJCenter2(http://jcenter.bintray.com/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
settings.gradle
rootProject.name = 'Rent In Cars'
apply from: '../node_modules/react-native-unimodules/gradle.groovy'
includeUnimodulesProjects()
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings)
include ':app'
jcenter()First of all, the jcenter() repository is deprecated now, so try not to use it. Remove all instances of jcenter() and the problem should be solved. Add mavenCentral() as a replacement.
jcenter()Everywhere you have mentioned jcenter(), expand it like this:
Groovy DSL:
jcenter() {
allowInsecureProtocol = true
}
Kotlin DSL:
jcenter() {
isAllowInsecureProtocol = true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With