24

My App was working fine, then i add com.splunk:mint-android-sdk, which required upper version of gradle, so i upgrade the gradle to from 2.1 to 3.3. after that i am facing issues. Please review my gradle file and help me out and please guide me how it work.( This is my first app but i want sure make its should be working fine in all scenario )

Error:Could not find com.android.tools.build:gradle:3.3.
Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.3/gradle-3.3.pom
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.3/gradle-3.3.jar
    https://plugins.gradle.org/m2/com/android/tools/build/gradle/3.3/gradle-3.3.pom
    https://plugins.gradle.org/m2/com/android/tools/build/gradle/3.3/gradle-3.3.jar
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.3/gradle-3.3.pom
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.3/gradle-3.3.jar
Required by:
    :MyApp:unspecified

My gradleare

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

    android {
    compileSdkVersion 23
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.example.abc.myApp"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled= true
        manifestPlaceholders = [onesignal_app_id: "hjaadsffsddd8-2e6hgf-4fdsasdfgb63-8dad5-1111111",
                                onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.getbase:floatingactionbutton:1.10.1'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'

    compile 'com.onesignal:OneSignal:[3.6.1,3.99.99]'
    compile 'com.google.firebase:firebase-core:9.2.0'                        
    compile 'com.google.firebase:firebase-messaging:9.2.0'
    compile 'com.splunk:mint-android-sdk:5.2.1'
}

and

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3'
       classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.splunk:mint-gradle-android-plugin:5.2.1'
    }
}
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
khawarPK
  • 2,179
  • 4
  • 20
  • 31
  • check here about [what-is-real-android-studio-gradle-version](https://stackoverflow.com/questions/51391708/what-is-real-android-studio-gradle-version/51392464#51392464) – shizhen Mar 04 '19 at 08:20

9 Answers9

31

Inside buildscript add google() then open terminal write command-- gradlew build and press enter.

enter image description here

repositories {
    google()
    jcenter()
}

NB: Make sure you are in active network connection

Md. Juyel Rana
  • 540
  • 5
  • 10
  • 4
    I got this error again `> Could not resolve all artifacts for configuration ':classpath'. > Could not find com.android.tools.build:gradle:3.3.2.` – Arar Apr 17 '19 at 03:49
6

You changed Gradle plugin version, not Gradle version

Set your Gradle Plugin version to 2.3
Then open gradle/wrapper/gradle-wrapper.properties and change Gradle version at line distributionUrl

DeKaNszn
  • 2,720
  • 3
  • 26
  • 26
4

Please follow these steps :

  1. Open Your project.

  2. Go to the Left side of the Gradle button.

  3. enter image description here

  4. Click button above image show .

  5. if this type of view you are not in offline mode.

  6. Go to Build and rebucild the project.

The above worked for me.

WaLid LamRaoui
  • 2,305
  • 2
  • 15
  • 33
MEGHA DOBARIYA
  • 1,622
  • 9
  • 7
3

This version of the gradle plugin doesn't exist.

classpath 'com.android.tools.build:gradle:3.3'

use the latest beta release:

classpath 'com.android.tools.build:gradle:3.0.0-beta6'

Instead if you would like to update gradle, update the distributionUrl in gradle-wrapper.properties.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 1
    Thanks @GabrieleMariotti and DeKaNszn Finally issue has been resolved with help of your suggestions. I updated following line of code: classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.google.gms:google-services:3.0.0' and distributionUrl in gradle-wrapper.properties 'distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip' and MOST IMPORTANT is FILE>SETTING>Build,Execution,Deployment>Build Tools>Gradles: Project-level settings: checked :Use default gradle wrapper(recommended) – khawarPK Sep 20 '17 at 09:04
  • @khawarPK I got this error `ERROR: Could not get unknown property 'pluginManagement' for settings 'Saif' of type org.gradle.initialization.DefaultSettings.` – Arar Apr 17 '19 at 04:03
2

I resolve my problem removing proxy configuration in file gradle.properties

Boken
  • 4,825
  • 10
  • 32
  • 42
1

I've got this error, and the problem was the antivirus Avast blocking android studio from download the files.

so I've disabled it temporary and also runned Android studio as an admin. this solved the problem.

Mimouni
  • 3,564
  • 3
  • 28
  • 37
1

In my case, I add maven { url 'https://maven.google.com' } at top of build script.

Hamidreza Shokouhi
  • 973
  • 1
  • 12
  • 24
0

Go to the gradle wrapper properties and see if the gradle version in the distribution url matches the one in the build.gradle classpath's

enter image description here

enter image description here

-1

I updated following line of

code: classpath 'com.android.tools.build:gradle:2.3.3' 
classpath 'com.google.gms:google-services:3.0.0' 

and distributionUrl in gradle-wrapper.properties 'distributionUrl=https\://services.gradle.org/distributions/‌​gradle-3.3-all.zip'

and MOST IMPORTANT is FILE>SETTING>Build,Execution,Deployment>Build Tools>Gradles: Project-level settings: checked :Use default gradle wrapper(recommended) FILE>SETTING>

khawarPK
  • 2,179
  • 4
  • 20
  • 31
  • I got this error `ERROR: Could not get unknown property 'pluginManagement' for settings 'Saif' of type org.gradle.initialization.DefaultSettings.` – Arar Apr 17 '19 at 04:06