0

A problem occurred evaluating root project 'my_app'. Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'

when i upgraded my app gradle version it shows me these errors tried so many ways but unable to resolve it please help me!

here is my build.gradle(project:my_app) file

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        maven { url "https://maven.google.com" }
        mavenCentral()
        flatDir {
            dirs 'libs'
        }
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.1'
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.14.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        maven { url "https://maven.google.com" }
        mavenCentral()
        flatDir {
            dirs 'libs'
        }
        gradlePluginPortal()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

my build.gradle(:app) file

plugins {
    id 'com.android.application' version '8.0.1' apply false
    id 'com.android.library' version '8.0.1' apply false
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

android {
    compileSdkVersion 33
    buildToolsVersion '33.0.2'
    namespace 'com.scanit.camscanner'

    defaultConfig {
        applicationId "com.scanit.camscanner"
        minSdkVersion 21
        targetSdkVersion 33
        versionCode 4
        versionName "1.2"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters 'armeabi-v7a', "arm64-v8a", 'x86', 'x86_64'
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    sourceSets {
        main {
            assets {
                srcDirs 'src\\main\\assets'
            }
        }
    }

    lintOptions {
        abortOnError false
    }
    aaptOptions {
        noCompress "tflite"
        noCompress "lite"
    }
    dependenciesInfo {
        includeInApk false
        includeInBundle false
    }

    /* Reduce apk size */
    /*splits {
        abi {
            enable true
            reset()
            include 'arm64-v8a', 'armeabi-v7a', 'mips', 'mips64', 'x86', 'x86_64'
            universalApk false
        }
    }*/

}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment:2.5.2'
    implementation 'androidx.navigation:navigation-ui:2.5.2'
    implementation project(path: ':scanlibrary')
    implementation project(path: ':sticker')
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    implementation 'com.google.android.gms:play-services-ads:20.2.0'
    implementation group: 'com.itextpdf', name: 'itextpdf', version: '5.5.9'
    implementation fileTree(dir: 'libs', include: '*.jar')
    implementation files('libs/itextpdf-5.5.13.2.jar')

    implementation group: 'cz.msebera.android', name: 'httpclient', version: '4.4.1.1'
    implementation 'com.github.pqpo:SmartCropper:v2.1.3'
    implementation 'com.github.chrisbanes:PhotoView:2.3.0'

    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

    implementation 'com.divyanshu.colorseekbar:colorseekbar:1.0.2'

    implementation 'androidx.annotation:annotation:1.6.0'
    implementation 'com.github.QuadFlask:colorpicker:0.0.15'
    implementation 'com.kyanogen.signatureview:signature-view:1.2'
    implementation 'com.github.nguyenhoanglam:ImagePicker:1.4.3'
    implementation 'com.takwolf.android:aspectratio:0.3.0'
    implementation 'com.huangyz0918:androidwm-light:0.1.2'
    implementation 'com.burhanrashid52:photoeditor:1.1.1'

    implementation 'com.google.android.gms:play-services-vision:20.1.3'

    implementation group: 'org.bouncycastle', name: 'bcprov-jdk15to18', version: '1.64'

    implementation 'jp.wasabeef:richeditor-android:2.0.0'
   implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
    implementation 'com.google.zxing:core:3.3.3'
    // https://mvnrepository.com/artifact/com.github.google/cameraview
//    implementation group: 'com.github.google', name: 'cameraview', version: '6ceaf867d3'

    api 'com.otaliastudios:cameraview:2.7.1'

    implementation 'com.github.yalantis:ucrop:2.2.6'
    implementation 'com.edmodo:cropper:1.0.1'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.intuit.sdp:sdp-android:1.0.6'
    implementation 'com.makeramen:roundedimageview:2.3.0'
    implementation 'com.onesignal:OneSignal:4.4.0'
    implementation 'com.android.billingclient:billing:4.0.0'

}

here is my settings.gradle file

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url 'https://maven.testfairy.com' }
        maven { url 'https://example.com/maven' }
    }
}

include ':sticker'
include ':scanlibrary'
include ':app'
rootProject.name = "my_app"
  • Does this answer your question? [Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'](https://stackoverflow.com/questions/69163511/build-was-configured-to-prefer-settings-repositories-over-project-repositories-b) – aled May 19 '23 at 12:16

0 Answers0