I keep getting this error when I try to build my project. I have no idea what is wrong with it and nothing I try is working.
I've trying cleaning, restarting Android Studio, and stopping the daemon with gradlew --stop.
Please help me!
Error:
Android Gradle plugin 3.0.1 must not be applied to project since version 3.0.1 was already applied to this project
Module:app script
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
apply plugin: 'com.android.library'
defaultConfig {
applicationId "com.example.joey.projectgenesis"
minSdkVersion 26
targetSdkVersion 26
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:gridlayout-v7:26.1.0'
}
Project script
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle.wrapper.properties
#Fri Jan 12 20:21:58 EST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
If you are creating just an app, remove apply plugin: 'com.android.library'.
If you are creating a library replace apply plugin: 'com.android.application' with apply plugin: 'com.android.library' and remove applicationId.
Refer this - Creating Android Libraries
My problem was much more silly. While doing find and replace, I had updated the versionCode to have a value in decimal.
Older values:
versionCode 253
versionName '2.53'
Newer values:
versionCode 2.54
versionName '2.54'
Having 2.54 for versionCode caused the issue. Changing that back to 254 did the trick for me!
Related
Please help me...
I want to create a project based on Google Maps. But after building gradle in Android Studio, The following error occurs:
ERROR:
Failed to resolve: com.google.android.gms:play-services-maps:17.0.0
Install Repository and sync project
Show in Project Structure dialog
Affected Modules: app
When i clicked on the 'Install Repository and ...' then this message appear:
Could not find dependency "com.google.android.gms:play-services-maps:17.0.0"
NOTE:
Gradle work online mode.
I went to Setting and Android SDK then downloaded google play services.. but it is not working for me.
I also set up a proxy.
EDIT:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
root gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After much effort, I was able to solve the problem.
Strange as it may seem, the problem was solved by manually adjusting the proxy.
thanks all.
I am new to Android. I built a simple login activity (just created it) and it my project is giving this error:
ERROR: Unable to resolve dependency for ':app#debug/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
I tried these solutions and they didnt work:
https://stackoverflow.com/questions/51218535/unable-to-resolve-dependency-for-appdebug-compileclasspath-could-not-resolv
https://stackoverflow.com/questions/47001656/unable-to-resolve-dependency-android-studio-3-0
My app gradle looks like this:
apply plugin: 'com.android.android'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:29.+'
implementation 'com.android.support:design:29.+'
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'
}
This is gradle app
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I don't understand how to resolve this issue considering I haven't even added question of my own. Please explain your solution step by step so I'm able to recreate to since this is literally the first project I created.
1 just figured out how to remove this Gradle error, follow the following steps.
Go to "File".
Click on Invalidate Cache/ Restart.
Again click on Invalidate Cache / Restart(On dialog window).
Let the Gradle build without any interruption
or
2
open the app.
go to gradle scripts.
then build.gradle(module:app)
finally inside dependecies type ( implementation 'com.android.support:appcompat-v7:27.+'
)
I deleted and reinstalled my android studio. The only thing that worked for me
When you are using
compileSdkVersion 29
buildToolsVersion "29.0.2"
Change
implementation 'com.android.support:appcompat-v7:29.+'
implementation 'com.android.support:design:29.+'
To
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
because google has changed the support libraries for androidX
in app gradle
change
apply plugin: 'com.android.android'
to
apply plugin: 'com.android.application'
All of a sudden my gradle build has become really really slow seams like its doing some extra work that it didn't used to do here is a picture from build :
as you can see there are a lot of tasks here it used to be build in like 10 seconds now it takes minutes to build whats wrong with it? it writes things in the bottom bar like resolving some libraries for kotlin and doing something related to caching "variant attribute matching cache" here is the picture :
i was trying to activate the annotation processor that it happend here is my gradle codes:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.moein.volley_download_kotlin"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions{
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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.tonyodev.fetch2downloaders:fetch2downloaders:2.0.0-RC21'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.dagger:dagger:2.13'
annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.13'
}
and the other code
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In gradle setting check work offline.
Clean and rebuild your project.
In gradle.properties in Gradle scripts directory(i.e., ~/.gradle/gradle.properties), add
org.gradle.parallel=true
org.gradle.daemon=true
This settings have helped me a lot.
I recently upgraded Android Studio to 3.1 and I am tuck with version conflict problem.My Gradle version is 4.4 and Andoid plugin version is 3.0.0. I tried changing it to 3.1.1.It gets reverted back to the previous version mumber. It is getting confusing for me,so your help is needed. When syncing I get the following message in the Build.
Version Conflict:
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.
build.gradle/app
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.globemaster.samples"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
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'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:design:27.0.0'
implementation 'com.payumoney.sdkui:plug-n-play:1.2.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Move this line at last
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.globemaster.samples"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
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'])
//
//
}
apply plugin: 'com.google.gms.google-services'
At the bottom of the (app)build.gradle script and rebuild the project.
Note:- I think that it has to do something with referencing
dependencies that have not yet been created. Something like calling a
variable before you even declare it
Pls add below code in your app build gradle.file
apply plugin: 'com.google.gms.google-services'
I hope this will work for you
Change your classpath to 3.1.1
classpath 'com.android.tools.build:gradle:3.1.1'
And apply plugin after dependencies in app gradle file
apply plugin: 'com.google.gms.google-services'
I recently update my Android Studio to version 3.0.1 and I started a new project with a blank activity. As soon as the gradle sync starts(as soon as I open the project)I get a message in Event Log :
Gradle sync failed: Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Could not determine artifacts for com.android.support:appcompat-v7:26.1.0
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.aar'.
Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.aar'.
Connect to dl.google.com:443 [dl.google.com/216.58.197.46] failed: Connection refused: connect
Connection refused: connect
Consult IDE log for more details (Help | Show Log) (3s 878ms)
I reinstalled the support repository from Android SDK manager and adding maven to the dependencies but so far have been unable to resolve the issue.
The build-gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app level build-gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.vishalbisht.test"
minSdkVersion 15
targetSdkVersion 26
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:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
}
I was able to get around this issue by commenting the following lines in app level build-gradle
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
and then it started working not sure if this is an acceptable solution but as of know I can at least run and compile my code.
Also after the Android studio 3.1 update, I have not faced this issue.
Change this
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.vishalbisht.test"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
To
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.example.vishalbisht.test"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
And Use any one of this google() or maven { url "https://maven.google.com" }
Read my Previous answer here
Most probably the solution would be as below
check target version in your app build.gradle
targetSdkVersion 30
Go to SDK manager and check whether you have the same SDK which should 30 as the API level
upgrade your Gradle and Gradle version plugin to the last version. and migrate your project to androidx.
classpath 'com.android.tools.build:gradle:3.5.1'
and gradle.wrapper
#Mon Nov 04 15:09:35 IRST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
I have deleted this in the build.gradle module and it worked.
maven { url "https://maven.google.com" }
as i was also using
google()
Check your build.gradle module and remove the dependencies highlighted in the error log.
Most likely you have added and obsolete dependency