Gradle fails to resolve dependencies in Android Studio - java

Whenever I add a dependency from an remote repository (jcenter) in Android Studio 1.1 (OS X) I get the following error upon syncing Gradle:
Error:(26, 13) Failed to resolve: <packagename:version>
My app's build.gradle is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "nl.timmevandermeer.cargoapp"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'org.json:json:20141113'
}
I have tried changing repositories (jcenter(), mavenCentral(), etc.), reinstalling Android Studio, JDK (7 and 8), changing Gradle version and Android SDK version, none of which worked. Upon running ./gradlew build I get:
Could not resolve com.android.tools.build:gradle:1.1.0.
13:48:04.914 [ERROR] [org.gradle.BuildExceptionReporter] Required by:
13:48:04.915 [ERROR] [org.gradle.BuildExceptionReporter] :CargoApp:unspecified
13:48:04.932 [ERROR] [org.gradle.BuildExceptionReporter] >
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
This is an error I get in other cases as well, for example when trying to use Intellij Idea instead of Android Studio. Running the app without the dependency does work though.

A similar problem here, and when I choose Build -> Clean Project
there is a "peer not authenticated" error.
solved by using "http://jcenter.bintray.com/" instead of "https://jcenter.bintray.com/"
repositories {
jcenter({url "http://jcenter.bintray.com/"})
}
hope this work for you.

I had a similar problem with a library on github, which stated to install it as:
dependencies {
compile 'com.github.chrisbanes.photoview:library:1.2.4'
}
This workaround seem to work, although it's suboptimal because it doesn't fetch a specific version and leads to Android Studio warnings:
dependencies {
compile 'com.github.chrisbanes.photoview:library:+'
}

In my case, the problem was I was declaring jitpack in buildscript.repositories instead of allprojects.repositories in my package build.gradle.
Instead of:
buildscript {
repositories {
...
maven {
url "https://jitpack.io"
}
}
}
It should be here:
allprojects {
repositories {
...
maven {
url "https://jitpack.io"
}
}
}

Rather late but probably your gradle works in offline mode.
Go to File->Settings->Gradle and uncheck the offline mode.
Then try to refresh gradle and it should work

I am behind a corporate firewall. I had my http settings set, but not my https settings. So, I added the following to my gradle.properties file:
systemProp.https.proxyPassword=...
systemProp.https.proxyHost=...
systemProp.https.nonProxyHosts=...
systemProp.https.proxyUser=...
systemProp.https.proxyPort=...

When I added this com.droidninja:filepicker:2.2.5 dependency in my build.gradle (Module Level) file then I got this error.
Failed to resolve: com.droidninja:filepicker:2.2.5
Then I added gradlePluginPortal() in settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// Add this line
gradlePluginPortal()
}
}
It worked for me.

Top build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
App build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "nl.timmevandermeer.cargoapp"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// compile fileTree(dir: 'libs', include: ['*.jar']) // <-- use gradle depedencies
compile 'com.android.support:appcompat-v7:22.0.0' // <-- brings in v4
// compile 'com.google.android.gms:play-services:7.0.0' // <-- will cause MultiDex exception, you need to choose which ones you want
// compile 'org.json:json:20141113' // <-- android comes with org.json
}
Multi-Dex Issue:
compile 'com.google.android.gms:play-services:7.0.0' is too big and should not be used directly. Please choose the modules you want here: http://developer.android.com/google/play-services/setup.html

I have similar problem -> ERROR: Failed to resolve:
solved by using maven { url 'https://jitpack.io' } instead of
maven {url 'https://maven.google.com/'}
I have added it in project level build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
It works fine.

Tested in UBUNTU - 14.04 ,
>delete .androidstudio1.2 , .gradle , .android , Android studio project from home directory
> Launch using studio.sh
>close the dialogue letting you choose new or old setting , just close it using that "x " button
> then it will set up an virtual nexus 5
>then there will be two errors saying problem about "sdk" and "gradle "
> Caution : choose the appropriate sdk version by clicking on the link given by where the problem is shown .
> close android studio
> reopen android studio
> then you will be thrown a possible error with jdk not found .
>go to file -> project structure
> give the path to jdk , in my case its "usr/local/java/jdk..."
>close android studio and open again , the gradle might work well after this .

In my case I added this to my build.gradle (module:app):
compile 'com.github.glomadrian:velocimeterlibrary:1.1#aar'
However, it gave me an error today. My solution is to use this instead:
compile 'com.github.glomadrian:velocimeterlibrary:+'

Related

Failed to resolve: com.google.firebase:firebase-core:16.0.1

I'm trying to add firebase cloud storage to my app. Below is the app build.gradle. But it says:
Failed to resolve: com.google.firebase:firebase-core:16.0.1.
Why? There is no firebase-core in the dependencies at all.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.louise.udacity.mydict"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.cloud:google-cloud-storage:1.31.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
}
apply plugin: 'com.google.gms.google-services'
From the docs:-
Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.
Add:
implementation 'com.google.firebase:firebase-core:16.0.1'
and in top level gradle file use the latest version of google play services:
classpath 'com.google.gms:google-services:4.0.2'
https://firebase.google.com/support/release-notes/android
https://bintray.com/android/android-tools/com.google.gms.google-services
Note:
You need to add the google() repo in the top level gradle file, as specified in the firebase docs and also it should be before jcenter():
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
https://firebase.google.com/docs/android/setup
As #Peter Haddad mentioned above,
To fix this issue I followed Google firebase integration guidelines and did the following changes in my app/build.gradle and project/build.gradle
Follow below mentioned link if you have any doubts
https://firebase.google.com/docs/android/setup
changes in app/build.gradle
implementation 'com.google.android.gms:play-services-base:15.0.2'
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.4.0"
Changes in Project/build.gradle
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.2.0'// // google-services plugin it should be latest if you are using firebase version 16.0 +
}
allprojects {
repositories {
google()// add it to top instead of bottom or somewhere in middle
mavenLocal()
mavenCentral()
maven {
url 'https://maven.google.com'
}
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
Add maven { url "https://maven.google.com" } to your root level build.gradle file
repositories {
maven { url "https://maven.google.com" }
flatDir {
dirs 'libs'
}
}
Since May 23, 2018 update, when you're using a firebase dependency, you must include the firebase-core dependency, too.
If adding it, you still having the error, try to update the gradle plugin in your gradle-wrapper.properties to 4.5 version:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
and resync the project.
I get the same issue and i solved it by replacing :
implementation 'com.google.firebase:firebase-core:16.0.1'
to
implementation 'com.google.firebase:firebase-core:15.0.2'
and everything solved and worked well.
What actually was missing for me and what made it work then was downloading'Google Play services' and 'Google Repository'
Go to: Settings -> Android SDK -> SDK Tools -> check/install Google Play services + repository
Hope it helps.
I was able to solve the issue by following these steps-
1.) This error occurs when you didn't connect your project to firebase.
Do that from Tools->Firebase if you are using Android studio version 2.2 or above.
2.) Make sure you have replaced the compile with implementation in dependencies in app/build.gradle
3.) Include your firebase dependency from the firebase docs. Everything should work fine now
This is rare, but there is a chance your project's gradle offline mode is enable, disable offline mode with the following steps;
In android studio, locate the file tab of the header and click
In the drop own menu, select settings
In the dialog produced, select "Build, Execution, Deploy" and then select "Gradle"
Finally uncheck the "offline work" check box and apply changes
If this doesn't work leave a comment describing your Logcat response and i'll try to help more.
In my case it was resolved by changing the compileSdkVersion and targetSdkVersion from 26 to 27
If you use Firebase in a library module, you need to apply the google play services gradle plugin to it in addition to the app(s) module(s), but also, you need to beware of version 4.2.0 (and 4.1.0) which are broken, and use version 4.0.2 instead.
Here's the issue: https://github.com/google/play-services-plugins/issues/22
if you are using
compileSdkVersion 23
in app-level gradle, and
classpath 'com.android.tools.build:gradle:2.1.0'
in project-level gradle
and you have added the
google-services.json file to your project.
you need to add just below code
maven {
url "https://maven.google.com"
}
at below of jcenter() in repositories blocks in project-level gradle file
here are my gradle files:
project-level gradle file:
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and app-level gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.moslem.amazonlikeapp"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
Just add below code and update all firebase versions that will work
implementation 'com.google.firebase:firebase-core:17.2.0'
If you receive an error stating the library cannot be found, check the Google maven repo for your library and version. I had a version suddenly disappear and make my builds fail.
https://maven.google.com/web/index.html
Go to
Settings -> Android SDK -> SDK Tools ->
and make sure you install Google Play Services

Unable to build gradle and create java class

Any project in my android studio fails to build.The error message is as follows-
Gradle sync failed: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.3-all.zip'.
Consult IDE log for more details (Help | Show Log)
Moreover i'm unable to make a new java class in android studio by File->new->Java class as no such option is available. I found some answers saying right click on java folder then clicking Mark Directory as -> SOurce root, even this option is not there . Moreover, for resolving the gradle issue, i found some answers saying click File->Invalidate Caches/Restart and delete the .gradle file in home directory then update android studio, i did accordingly but still nothing works.
build.gradle contents are-
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.iitmandi"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
testCompile 'junit:junit:4.12'
}
Contents of gradle-wrapper.properties are-
#Tue Mar 28 20:10:53 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Build.grale-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
on doing Build->Clean project this error message was shown-
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugUnitTestApkCopy'.
> Could not resolve junit:junit:4.12.
Required by:
project :app
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out
I even uninstalled Android-Studio 2.3 and installed 2.2.2 instead but still the problem persists
the code in JUnit library is referenced in the project but there is no related JUnit dependent library yet...you either have to delete the referencing line(s) of code in the gradle or install the JUnit library.For more info https://debugah.com/failed-to-resolve-junitjunit4-12-how-to-solve-11544/

Upgrade Android Studio to 2.1.2 and now getting build errors

My project built fine before, but now when upgrading to Android Studio 2.1.2 I get an error:
Here is what I have in my build.gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId "com.puc.mobile"
minSdkVersion 14
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
//compile files('libs/crashlytics.jar')
compile files('libs/FLurry_3.2.2.jar')
compile files('libs/universal-image-loader-1.9.2.jar')
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Google Repository through the SDK manager to use this dependency.
compile files('libs/commons-lang3-3.4.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.7#aar') {
transitive = true;
}
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile files('libs/Parse-1.13.0.jar')
compile 'com.android.support:support-v4:19.0.0'
compile 'com.google.android.gms:play-services:9.2.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.google.android.gms:play-services-ads:9.2.0'
compile 'com.google.android.gms:play-services-auth:9.2.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
}
I realize there are some issues here with build tool versions, but honestly I am not sure how to fix it. Any clues?
UPDATE:
After updating the buildToolsVersion as mentioned below, I get the errors:
It happens because Build Tools revision 19.1.0 doesn't exist.
The latest version is 23.0.3.
These tools is included in the SDK package and installed in the <sdk>/build-tools/ directory.
Change in your build.gradle
android {
buildToolsVersion "23.0.3"
// ...
}
SDK Build Tools Release Notes

Gradle sync failed: Unable to find method

I try to import a project in Android studio. When importing it, i've got an Error with Gradle :
Gradle sync failed: Unable to find method
'org.gradle.api.artifacts.Configuration.setExtendsFrom(Ljava/lang/Iterable;)Lorg/gradle/api/artifacts/Configuration;'.
I have tried :
Re-download dependencies and sync project: Fail (same error).
Stop Gradle build processes: Fail (same error).
Delete the .graddle in the home directory: Fail (same error).
Invalidate cache and restart Fail (same error).
Uninstall and reinstall Android studio and SDK: Fail (same error).
/build.gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
/app/build.gradle
apply plugin: 'com.android.application'
//apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'xxx.xxx.xxx'
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName '1.0'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildPB {
debuggable false
jniDebuggable false
renderscriptDebuggable false
zipAlignEnabled true
}
}
productFlavors {
}
// lintOptions {
// abortOnError false
// }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile ('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'net.sf.opencsv:opencsv:2.3'
compile 'de.greenrobot:greendao:1.3.7'
// You must install or update the Support Repository through the SDK manager to use this dependency.
// compile 'com.android.support:support-v4:19.+'
}
I fixed the error by changing the following things.
Open the file under your-app-project\your-app-name\gradle\wrapper\gradle-wrapper.properties
replace the old URL path by this one:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Rename the folder name from "...\1.12" to your-app-project\your-app-name\.gradle\2.10
Change the classpath of your-app-project\your-app-name\build.gradle to
classpath 'com.android.tools.build:gradle:2.1.2'
Replace runProguard of your-app-project\your-app-name\app\build.gradle by minifyEnabled
Click Retry on the error reminder or Reopen your Android Studio and project.
I am using the latest versions of Android Studio and Gradle.
edit Project >> App >> gradle >> wrapper >> gradle-wrapper.properties
distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-bin.zip
rebuild the project (restart ide in your mind)
Project >> App >> gradle >> wrapper >> gradle-wrapper.properties
https\://services.gradle.org/distributions/gradle-4.1-all.zip
This will surely work. I was having same issue. Solved by this.
This issue appears when I updated my android studio to 3.1.1
1.
I have resolved it by changing:
classpath 'com.android.tools.build:gradle:3.1.1'
in build.gradle (project)
2.
change:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
in gradle-wrapper.properties.
(you can check it in explorer C:\Program Files\Android\Android Studio\gradle\gradle-4.4)
I faced similar issue and i resolved it by
Android Studio Version 3.0.1
1.Change the classpath of your-app-project\your-app-name\build.gradle to classpath 'com.android.tools.build:gradle:3.0.1'.
2.Replace the old URL path by this one: distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
My gradle file was of version 4.1
ie; file in following location:(may differ slightly in your machine)
C:\Program Files\Android\Android Studio\gradle\gradle-4.1
Under gradle->gradle-wrapper.properties
replacing
distributionUrl=https\\://services.gradle.org/distributions/gradle-2.2.1-all.zip
with
distributionUrl=https\\://services.gradle.org/distributions/gradle-4.1-all.zip
solved the issue.
This issue happened to me today with Android Studio 2.2 Beta2 on Windows 7 64-bit.
None of the solutions mentioned helped. Finally I was able to resolve the issue by re-importing my project.
For me the solution was to open Settings -> Build, Execution, Deployment -> Gradle and check "Use default gradle wrapper (recommended)".
I was able to copy over the /.gradle folder from a new Android project into the one that was having the problem. Then I restarted Android Studio and did a clean/build. This resolved my issue.
After 1 hour R&D Not Solution as worked for me...
But still i have solution follow this its work 100
step 1: upgrade your build.gradle(Project:<your project name>)
Example : classpath 'com.android.tools.build:gradle:2.1.3' // old gradle file
classpath 'com.android.tools.build:gradle:2.3.1' // upgraded file
OR
classpath 'com.android.tools.build:gradle:3.1.0'
Step 2 : Upgrade compileSdkVersion buildToolsVersion
Example : compileSdkVersion 23 buildToolsVersion "23.0.3 // old api's
compileSdkVersion 25 buildToolsVersion "25.0.2" // upgraded api's
Step 3: upgrade gradle-wrapper.properties
Example : distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip // old or any version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip // new or any version
Step 4 : finally goto build>rebuild project...
......End #Ambilpura
The answer is partially reduntant, but it's for those who are confused with what version of gradle distribution to add.
It's the gradle version that's installed on your machine.
Ex:
Check your gradle version by:
"gradle -v" (mine was 5.4.1)
Update the file "your-app-project\your-app-name\gradle\wrapper\gradle-wrapper.properties" with
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
And done! It solved the problem for me.

SafePassmaster ---> Error:(1, 0) Plugin with id 'com.android.application' not found

I have imported a android source code from Github and while syncing the gradle process I have got an error
Error:(1, 0) Plugin with id 'com.android.application' not found.
Open File
This is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "activities.safepassbeta"
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
}
Try changing the classpath in the top level build.gradle file to 'com.android.tools.build:gradle:2.0.0-beta7' and the distributionUrl value in gradle-wrapper.properties file to https://services.gradle.org/distributions/gradle-2.10-all.zip.
Make sure that in the settings for gradle in the 'Build, execution and deployment' section, you have set the preference to 'Use default gradle wrapper'.
As the other answer described, try changing the classpath in the top level build.gradle file. The file you show is the application build.gradle, not the top level build.gradle file. For Android Studio 3, you can try using 'com.android.tools.build:gradle:3.0.1'. The problem is that the gradle dependency is not downloading properly, usually because of improper settings for the url to use to download gradle. This is a common problem. If the problem persists look into solutions for how to set up gradle, such as Manually install Gradle and use it in Android Studio
A quick-and-easy fix is to look at your previous projects which work on your IDE, look at what version of gradle they are using. If you use that version of gradle in this project it will most likely work.
However, the 'proper' solution is to set up the distributionUrl properly. Worst come to worst, if that does not work, you could also try manually downloading Gradle to use it in your project.

Categories

Resources