49

I am using android studio 3.1.4.

Error:Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1). Searched in the following locations: https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar

Jolta
  • 2,620
  • 1
  • 29
  • 42
Rohan Patel
  • 1,758
  • 2
  • 21
  • 38
  • possible duplicate with: https://stackoverflow.com/questions/51072319/android-studio-3-1-3-gradle-sync-error-could-not-download-gradle-core-jar/51151050#51151050 – shizhen Oct 24 '18 at 05:31
  • For anyone arriving here due to the _same_ error message when building for Android in Unity, see [this](https://stackoverflow.com/questions/52957079/gradle-build-for-android-in-unity-fails-saying-that-it-could-not-find-intellij) SO question for a slightly different solution. – Glen Despaux Jr Oct 23 '18 at 21:59
  • 3
    None of the answers have solved my issue. Getting the same error on a React Native project. – burakcalik Oct 24 '18 at 13:36
  • 1
    I am also getting the same – Jothi Kannan Oct 24 '18 at 14:26
  • I'm getting this error when trying to follow the instructions for setting up and running Flutter on Linux: https://flutter.io/setup-linux/ None of the provided answers have worked so far. – vzipp Oct 24 '18 at 15:17
  • 1
    @burakcalik if that's a problem with on of the sub-modules you're using, it may be that this submodule has a wrong order amongst it's dependencies and not your :app module itself. I experienced that here https://github.com/square/react-native-square-reader-sdk/issues/30 – SudoPlz Oct 24 '18 at 18:46

13 Answers13

41

I was able to fix the issue by changing the order of the repositories here:

/platforms/android/CordovaLib/build.gradle

from this:

repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

to this:

repositories {
    maven {
        url "https://maven.google.com"
    }
    jcenter()
}
devsnd
  • 7,382
  • 3
  • 42
  • 50
14

If you're using classpath 'com.android.tools.build:gradle:3.0.1' or higher in your project/build.gradle, the solution is:

Add "google()" to your project/build.gradle file in 2 places:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        ...
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

Then you will see in the logs that intellij-core.jar is downloaded from different URLs:

Mr-IDE
  • 7,051
  • 1
  • 53
  • 59
7

To resolve this issue either put

<preference name="android-targetSdkVersion" value="27" />

into your config.xml.

Or even better, upgrade android-cordova to the lates version (7.1.2):

cordova platform add android@7.1.2

android-cordova 7.1.2 includes fix CB-14127: "Move google maven repo ahead of jcenter". (https://issues.apache.org/jira/browse/CB-14127)

Lukas
  • 2,544
  • 2
  • 18
  • 33
  • upgrading to android-cordova 7.1.1 doesn't fix the problem, as stated in other comments the problem is still reproducible – Alexandru Mincu Oct 24 '18 at 20:13
  • They fixed it in /platforms/adnroid/build.gradle but not in /platforms/android/CordovaLib/build.gradle so the build still fails – Tim Stopfer Nov 02 '18 at 10:23
7

I solve my problem; change the platform/android/CordovaLib/build.gradle file. I put the maven repo ahead the jcenter:

repositories {
    maven {
        url "https://maven.google.com"
    }
    jcenter()

}

And I use cordova-android 7.1.1.

Armali
  • 18,255
  • 14
  • 57
  • 171
Costas Bakoulias
  • 895
  • 9
  • 11
3

hey guys I came across the same problem, which is actually a conflict between the ionic, gradle and gradle plugin. It turns out that in the new version of the gradle plugin the build is now dependent on the google repository. To get around the problem you need to change 2 files:

Make sure they are as described below!

1 ° - “platforms / android / CordovaLib / build.gradle”

buildscript {
 repositories {
  google()
  maven {
   url “https://maven.google.com”
  }
  jcenter ()
}

2 ° - “platforms / android / build.gradle”

buildscript {
 repositories {
  google()
  maven {
   url “https://maven.google.com”
  }
  jcenter ()
 }

and

 allprojects {
  repositories {
  google()
  maven {
   url “https://maven.google.com”
  }
  jcenter ()
 }

This is it. Hope this helps!

2

For me, problem solved change build gradle files to get Google Server.
/platforms/android/build.gradle

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

/platforms/android/app/build.gradle

allprojects {
    repositories {
        google()
        mavenCentral();
        jcenter()
    }
2

https://github.com/flutter/flutter/pull/23397

In short, following Mahi-K from the above link, you have to edit $flutterRoot/packages/flutter_tools/gradle/flutter.gradle

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://dl.google.com/dl/android/maven2'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

In the gradle wrapper properties gradle/wrapper/gradle-wrapper.properties you may also have to change it to 4.6 or above

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
vzipp
  • 350
  • 3
  • 8
1

Use com.android.tools.build:gradle:3.2.1

You'll also have to update your '/gradle/wrapper/gradle-wrapper.properties'

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
  • Of course you'll run into further issue with older apis like aapt etc. Another workaround is to just copy someone else's existing '~/.gradle' folder to your '~/'. But that's just a barbaric hack. :-D – Arpit Anand Oct 23 '18 at 11:38
  • 2
    didn't fix it for me – flunder Oct 23 '18 at 14:57
1

In addition to devsnd and Mr-IDE's answers, Here are the suggestions:

  • Place 'google()' in the first order in both buildscript repositories and allprojects repositories of Project-level Gradle build file.

  • Check the consistency in the Android Gradle Plugin version and Gradle version. Generally, they are automatically updated with Android Studio, but you might have an older project. Plugin 3.1 should use Gradle version 4.4 and above, Plugin 3.2 should use Gradle version 4.6 and above.

  • Install that particular buildToolsVersion that plugin uses.

Check out this link for more details:

https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

Hope this helps.

Joshua Kim
  • 57
  • 4
nkhar
  • 225
  • 1
  • 4
  • 13
1

Adding google() to the build.gradle files uses this URL https://dl.google.com/dl/android/maven2/ which returns 404 at the moment.

(source: https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/dsl/RepositoryHandler.html#google--)

At the moment, the working URL is https://dl.google.com/dl/android/maven2/index.html You can reach it by replacing google() with this line

maven { url 'https://maven.google.com' }

in your build.gradle files.

sonjaBrzak
  • 41
  • 7
1

This issue is being tracked on Jira

A break down of the issue

Basically there was a problem uploading Google jars to jcenter and it is causing builds to fail.

The fix

Builds will work if we put the google maven repo ahead of jcenter.

On the 18th July the issue should have been addressed in the release of cordova-android 7.1.1, see change log here

The fix however did not work in all cases evidently.

A new fix has been made so expect this to be ready in 7.1.2, until then, remember to swap the ordering every time you remove and re-add the platform.

Ryan Searle
  • 1,597
  • 1
  • 19
  • 30
0

Downgrading to:

com.android.tools.build:gradle:3.1.0

form

com.android.tools.build:gradle:3.2.1

Solved the Problem

also: i put google() at first

I'm using Android Studio 3.2.1

ExceedLimits
  • 141
  • 3
0

What worked for me was going to the Build.Gradle, and going to where it says the following:

dependencies { classpath "com.android.tools.build:gradle:4.1.1"

If you are getting the same Tag Mismatch issue I got from this error, then click on the highlighted "com.android.tools.build:gradle" part and then press alt enter.

If it asks you to sync, sync, then click it again and press Alt Enter and it should ask you to upgrade. Click yes. It will upgrade to the latest version.

Now generate your signed APK and it should work now.

That is, if the lint is highlighting it. If it isn't than I don't know what the problem is.

It could be the result of an older Gradle dependency changing and a newer one taking precedence. That's my theory. I fixed my problem anyhow.