I already looked at every other questions and googled the impossible but I cannot find a way to use correct dependencies. Below there is my app Gradle build file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha01'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
google()
}
android {
compileSdkVersion 27
Hey just exclude the appcompat dependencies from the libraries which are using an older version of appcompat and support libraries. If you don't have these support libraries in your project then include them. In your question, braintreepayments is one of the libraries which using an older version of card view and design library. Try changing your gradle dependencies to
dependencies {
...
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation ('com.braintreepayments.api:drop-in:3.0.0'){
exclude group: 'com.android.support'
}
...
}
You should either downgrade appcompat library so its version be lowe then build tools version but still 27th, or upgrade build tools version up to appcompat. Check different compounds to find completely the same verstion
Remove buildToolsVersion "27.0.3" from your gradle file.
Or you should check this-- buildToolsVersion "27".
Good luck
(Posted on behalf of the question author).
The problem, as mudit_sen helped me find out, was the Braintree dependency:
implementation 'com.braintreepayments.api:drop-in:3.0.0'
I removed that line as I don't need it and it was from a previous project and now everything is working as intended. Thank you very much.
Update
For people that wants to use Braintree library the solution to me was to use
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:support-v4:27.0.0'
with
implementation 'com.braintreepayments.api:drop-in:3.4.0'
Related
Trying to create a simple app with FireStore and Google Authentication. Having problem with the gradle:
In project 'app' a resolved Google Play services library dependency
depends on another at an exact version (e.g. "[15.0. 1]", but isn't
being resolved to that version. Behavior exhibited by the library will
be unknown.
Dependency failing: com.google.android.gms:play-services-flags:15.0.1
-> com.google.android.gms:play-services-basement#[
15.0.1], but play-services-basement version was 16.0.1.
The following dependencies are project dependencies that are direct or
have transitive dependencies that lead to the art ifact with the
issue.
-- Project 'app' depends onto com.google.firebase:firebase-firestore#17.1.5
-- Project 'app' depends onto com.firebaseui:firebase-ui-auth#4.2.0
For extended debugging info execute Gradle from the command line with
./gradlew --info :app:assembleDebug to see the dep endency paths to
the artifact. This error message came from the google-services Gradle
plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding
"googleServices { disableVersionCheck = false }" to your b uild.gradle
file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "myapp.com"
minSdkVersion 19
targetSdkVersion 27
versionCode 11
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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.3'
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.firebase:firebase-firestore:17.1.5'
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin
Project gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
}
Can somebody help me?
There are many answers here for individual solutions that do not really get down to the problem. Here is how to solve this in general:
As the original log output suggests, it is useful to run the build in the terminal with the following command:
./gradlew --info assembleDebug
This will give you a list of all dependencies that are involved in the conflict. It looks similar to this (I removed the package name stuff to make it a bit more readable):
Dependency Resolution Help: Displaying all currently known paths to any version of the dependency: Artifact(groupId=com.google.firebase, artifactId=firebase-iid)
-- task/module dep -> firebase-analytics#17.2.0
---- firebase-analytics:17.2.0 library depends -> play-services-measurement-api#17.2.0
------ play-services-measurement-api:17.2.0 library depends -> firebase-iid#19.0.0
-- task/module dep -> firebase-core#17.2.0
---- firebase-core:17.2.0 library depends -> firebase-analytics#17.2.0
------ firebase-analytics:17.2.0 library depends -> play-services-measurement-api#17.2.0
-------- play-services-measurement-api:17.2.0 library depends -> firebase-iid#19.0.0
-- task/module dep -> play-services-measurement-api#17.2.0
---- play-services-measurement-api:17.2.0 library depends -> firebase-iid#19.0.0
-- task/module dep -> firebase-iid#19.0.0
-- task/module dep -> firebase-messaging#17.1.0
---- firebase-messaging:17.1.0 library depends -> firebase-iid#[16.2.0]
-- task/module dep -> com.pressenger:sdk#4.8.0
---- com.pressenger:sdk:4.8.0 library depends -> firebase-messaging#17.1.0
------ firebase-messaging:17.1.0 library depends -> firebase-iid#[16.2.0]
From this list you get to know 2 things:
Where is the conflicting depedency found
What versions of the conflicting dependency are set up
In my case the conflicting dependency is firebase-iid: It's either #19.0.0 or #16.2.0
To fix this you must define the top-level dependency of the wrong firebase-iid explicitly in your build.gralde.
So in the upper log you can see that there are 2 examples of an out-dated version of firebase-iid#16.2.0. One comes from -- task/module dep -> firebase-messaging#17.1.0 the other one from a third-party library (pressenger). We don't have influence on the third-party library, so nothing to do here.
But for the other dependency, we have to declare it explicitly with the correct version:
implementation 'com.google.firebase:firebase-messaging:20.0.0'
Now the build works again. Happy ending :)
There's a known bug with Google Services 4.2.0 that may cause this. Downgrading your google-services version to 4.1.0 in your project's build.gradle may resolve the issue
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.1.0' //decreased from 4.2.0
}
}
The problem was it was missing a dependency.
Adding com.google.firebase:firebase-auth solved the issue.
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.3'
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.firebase:firebase-firestore:17.1.5'
// implementation'com.google.firebase:firebase-core:16.0.6'
// implementation'com.google.firebase:firebase-storage:16.0.5'
implementation'com.google.firebase:firebase-auth:16.1.0' => add this line
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
}
There was a bug related to google-services that was eventually fixed in version 4.3.3.
So you can either use 4.3.3 or the latest version (check here)
classpath 'com.google.gms:google-services:4.3.3' // or latest version
or downgrade to 4.1.0
classpath 'com.google.gms:google-services:4.1.0'
i added the latest version of firebase messaging to build.gradle (Module: app) in my project and problem solved
implementation 'com.google.firebase:firebase-messaging:20.0.0'
Your app/build.gradle might have these lemon color blocked on dependencies part in Android Studio like on the picture below,
These (lemon color blocks) mean it's not latest version of dependency. just put mouse on each block, then IDE (Android Studio) tells the numbers that have to be changed.
Updating all my Google Play Services libraries to the latest in ALL modules solved the issue for me. I don't see that you have any Google Play Services libraries, but I wanna leave this answer here to those that might find this useful.
My project was working fine (No build issues). All of a sudden, I got this error
"resolved Google Play services library dependency depends on another at an exact version.."
I figured out that it was because I was building offline.
If anyone gets the same error, check if you are building offline.
Thanks, but unfortunately, this didn't entirely work for me. I also had to add the following to my build.grade (Module:app)
implementation 'com.google.android.gms:play-services-flags:16.0.1'
implementation 'com.google.android.gms:play-services-basement:16.0.1'
The problem was fixed after upgrading this lib in my project's build.gradle:
classpath 'com.google.gms:google-services:4.3.3'
and these ones in the app module's build.gradle:
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.google.firebase:firebase-messaging:20.1.5'
After this, use Android Studio's Clean menu
I am using One Signal and caught this error once a time.
The reason was:
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
to put apply plugin for one signal before 'com.android.application'.
Maybe this will be useful for some other apply plugin too.
Add FCM to your App added Lower dependency Then I changed the dependency to the latest version this problem has solved.
compile 'com.google.firebase:firebase-messaging:17.3.4'
to
implementation 'com.google.firebase:firebase-messaging:20.0.0'
None of the other answers worked for me. My use-case is with React-Native 61+ trying to setup FCM and Analytics. What worked for me was using the latest google-services in android/build.gradle
dependencies {
classpath "com.android.tools.build:gradle:3.4.2"
classpath "com.google.gms:google-services:4.3.3" // Need the latest here
}
And then adding the gradle dependencies to android/app/build.gradle required for the products I'm using (in my case Analytics and Cloud Messaging) from here
dependencies {
...
// add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
...
}
I just tried #live-love's accepted answer myself and agree with the approach.
It might be more precise, however, to correct your dependencies according to the latest Google Services library version.
For my case, it happened when I just added/activated a Firebase service to the app.
You need to follow the latest version in project and Gradle app.
My app/build.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
//Android Support Design Library
implementation 'com.android.support:design:27.1.1'
//RecyclerView
implementation 'com.android.support:recyclerview-v7:27.1.1'
// Support multidex
implementation 'com.android.support:multidex:1.0.3'
// Firebase Core
// implementation 'com.google.firebase:firebase-core:16.0.1'
//Firebase Authentication
implementation 'com.google.firebase:firebase-auth:19.3.1'
// Firestore Firestore
implementation 'com.google.firebase:firebase-firestore:21.4.3'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
// glide
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
// Circle ImageView
implementation 'de.hdodenhof:circleimageview:2.2.0'
}
apply plugin: 'com.google.gms.google-services'
My project's build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Don't forget to sync the Gradle again.
The working solution for me was to remove "firebase-auth" and add "firebase-core" dependency. But after a couple of project rebuilds I started experiencing another compilation issue so I had to add the "firebase-auth" dependency in addition to the "firebase-core" in order to make it work:
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
Add the line below in you Project's build.gradle (See image below)
classpath 'com.google.gms:google-services:4.3.3'
Then update your Firebase related packages by going to :
File > Project Structure > Dependencies > app
Update Firebase modules to latest version (See the image below)
In my case I am using :
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-messaging:20.1.7'
implementation 'com.google.firebase:firebase-core:17.4.0'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
Don't forget to add :
apply plugin: 'com.google.gms.google-services'
See my Module's build.gradle file below.
The ML Kit library had versioning problems in the latest release.
Google Play services library dependency depends on another at an exact version error (thrown by the google-services plugin)
Here is the link to the solution.
https://firebase.google.com/support/release-notes/android#bom_v25-8-0
This is new thing happen to me that If your network is not secure and you are getting prompt of Untrusted Certificate.
If you will Accept or Reject, It will give this error until your network will not be secure.
You can work offline by checking Setting -> Gradle -> Offline Mode
If you used song haesuk answer, you need to do it for both build.gradle Project (classpath in dependencies), and in build.gradle app (implementations). Also do the same if you change builds for any libraries imported to the app.
I use suggestions provided by android studio and it changed implementations but did not change dependencies hence during build, there was a conflict between the two and it gave me same error.
I replicated the issue when I accidentally added com.google.firebase:firebase-ml-vision twice with different versions.
I resolved it by simply clearing the app-level dependencies block leaving just the default Android dependencies like so:
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'androidx.multidex:multidex:2.0.0'
}
This worked for me!
dependencies {
classpath "com.android.tools.build:gradle:3.4.2"
classpath "com.google.gms:google-services:4.3.3" // Need the latest here
}
dependencies {
...
// add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
...
}
In my case updating the firebase-bom and play services library to their latest version solved the issue:
In app level gradle :
implementation platform('com.google.firebase:firebase-bom:30.3.2')
In project level gradle :
classpath 'com.google.gms:google-services:4.3.13'
While adding dependency implementation 'com.azoft.carousellayoutmanager:carousel:1.2.4' to my project, Android Studio throws exception Failed to resolve: recyclerview-v7. Then I tried adding dependency for recyclerview. Still getting same error.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.someapp"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
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:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-crash:16.0.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.3.1'
implementation 'com.commonsware.cwac:saferoom:0.4.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.support:cardview-v7:27.1.1'
}
apply plugin: 'com.google.gms.google-services'
I have same problem and i'm change order of repositories in biuld.gradle (app) and problem solved.
Change :
jcenter()
google()
To :
google()
jcenter()
Hope it's help
In Android Studio go to build.gradle (Project: YourProjectName), NOT the build.gradle (Module: app)
Change the code, so it looks like this (switch google() and jcenter()):
allprojects {
repositories {
google()
jcenter()
}
}
Add maven to repositories and it should work
I have no idea why. But my exact same problem has been solved with commenting all of android support dependencies.
It's so strange. But now my project runs without adding another version of these dependencies. When I put only one of these dependencies, I have a warning between ver 27.1.1 and 28.0.0 of support libraries. But I've only used version 28 on this project. It means there is all of these dependencies somewhere in the gradle which obviously is not written by me, or may be it's in the sth like cache (So strange bug).
implementation "com.android.support:support-v4:28.0.0"
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:support-vector-drawable:28.0.0"
implementation "com.android.support:recyclerview-v7:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation "com.android.support.constraint:constraint-layout:1.1.3"
If any of the above solutions did not work try to remove Maven repository and resync again.
this line in build.gradle
maven {
url "https://storage.googleapis.com/snap-kit-build/maven"
}
That's work for me in some projects.
Or replace this line
'com.android.support:recyclerview-v7:27.....'
With this line
'com.android.support:recyclerview-v7:28.0.0-alpha3'
That will solve your problem.
It cannot resolve because the version you are adding might not be in the Maven repository. Check your Api level and choose the appropriate version.
This link might be of help.
Finally I found a solution. Upgrading all the support dependencies to the latest version, solved the issue. You can check the latest version of dependencies here. I upgraded the support dependencies to the latest version 28.0.0-alpha3. It solved my problem.
I had the same error Failed to resolve: recyclerview-v7. Even though project worked before and I just moved it to another machine without changes in gradle files.
Full clear of gradle service folder helped me. By default it is located in C:\Users\username\.gradle
I closed Android Studio and deleted that folder. After that gradle made clean sync and it ended with success.
Maybe deleting of only cached libraries in C:\Users\username\.gradle\caches\modules-2\files-2.1\com.android.support\recyclerview-v7 would help but I didn't check it.
You have to exclude recyclerview-v7 module from the library you want to add:
compile ('YOUR_DEPENDENCY') {
exclude module: 'recyclerview-v7'
}
You have to use for example this dependency: implementation 'com.android.support:recyclerview-v7:28.0.0' in your build.gradle(Module: app) and use 'sync project with Gradle Files' then it will get this dependency. It should work then.
in androidx version I added implementation "androidx.recyclerview:recyclerview:1.1.0" to my gradle and it solved the issue
I have an Android studio project in which I have added a Java library module, which I call core. My three Gradle build files look like this.
project/build.gradle
buildscript {
ext.kotlin_version = '1.2.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
core/build.gradle
apply plugin: 'java-library'
apply plugin: 'kotlin'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
...
}
app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android { ... }
dependencies {
implementation project(':core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
testImplementation 'junit:junit:4.12'
}
The problem I have is that, in core/build.gradle, the kotlin-stdlib-jdk7 line is giving me the warning Plugin version (1.2.40) is not the same as library version (jdk7-1.2.40). I have tried changing it to:
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.40"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.40"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
But the warning is still there. The build still runs successfully, and I know I can surpress the warning without any problems and ignore it, but I really want to know why this is happening and how I can get rid of it. I am using Android Studio 3.0.1. Does anyone know of a solution to this?
Starting from Kotlin 1.4 dependency on the standard library added by default:
You no longer need to declare a dependency on the stdlib library in any Kotlin Gradle project, including a multiplatform one. The dependency is added by default.
The automatically added standard library will be the same version of the Kotlin Gradle plugin, since they have the same versioning.
For platform-specific source sets, the corresponding platform-specific variant of the library is used, while a common standard library is added to the rest. The Kotlin Gradle plugin will select the appropriate JVM standard library depending on the kotlinOptions.jvmTarget compiler option of your Gradle build script.
Link to Kotlin Gradle plugin documentation.
This is a bug in the Kotlin plugin. I've filed an issue in the Kotlin issue tracker. You can simply ignore the message.
EDIT: JetBrains marked the issue as a duplicate of KT-23744 "Kotlin library and Gradle plugin versions are different" inspection false positive for non-JVM dependencies".
Solution, in my case, I got rid of the line
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
in the app level Gradle and the warning disappear
As the Kotlin page says :
" You no longer need to declare a dependency on the stdlib library in any Kotlin Gradle project, including a multiplatform one. The dependency is added by default.
The automatically added standard library will be the same version of the Kotlin Gradle plugin, since they have the same versioning.
For platform-specific source sets, the corresponding platform-specific variant of the library is used, while a common standard library is added to the rest. The Kotlin Gradle plugin will select the appropriate JVM standard library depending on the kotlinOptions.jvmTarget compiler option of your Gradle build script."
You might be facing this after upgrading kotlin version, Actually, older versions are still in your caches, In this case, you need to do the following steps
Invalidate cache
Clean project
Sync project with gradle files
Now your warning will be gone.
[build.gradle(Module)]
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.5.10'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10'
...
}
My project automatically added
(implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10')
to the project build file. After moving the implementation to the module file, and removing
(implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10')
the warning went away.
The 'stdlib' needs to match the 'stdlib-jdk' in the module file.
I faced the same issue while using Firebase with Kotlin.
I had to upgrade all the dependencies with their latest version available.
Note: have your kotlin-reflect and kotlin-stdlib versions same.
after many days i have solve the issue
Update the kotlin_version to '1.4.32'
In my case, I set the version number for all modules the same as gradle of app as latest version, and problem resolved.
I know about this questions:
Failed to resolve: com.android.support:cardview-v7:26.0.0 android
Could not resolve com.android.support:appcompat-v7:26.1.0 [duplicate]
And I've read this documentations:
Migrate to Android Plugin for Gradle 3.0.0
Migrating to Android 8.0
So I'm posting this question believing its not a duplicate.
I've installed Android Studio 3.0.1. I didn't have any previous version before and I started a new project.
Every setting in Gradle file have been set by Android Studio itself and I've checked them all.
These are the file contents:
build.gradle (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.administrator.as301test"
minSdkVersion 16
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.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.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'
}
Top level build.gradle
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
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
I use google() in repositories as here clearly says:
// If you're using a version of Gradle lower than 4.1, you must instead use:
// maven {
// url 'https://maven.google.com'
// }
My gradle version is 4.1 so I don't need above code.
But I still get this error as the others have been asking about:
Error:Unable to resolve dependency for ':app#debug/compileClasspath':
Could not resolve com.android.support:appcompat-v7:26.1.0.
Why should I get this error when I'm creating a new project in AS 3.0.1 and it has been set all the necessary settings?
Update
#Rohit's answer somehow solved the issue but I still get same error for some other dependencies.
Could not resolve com.android.support.test:runner:1.0.1
Could not resolve
com.android.support.test.espresso:espresso-core:3.0.1
Could not resolve junit:junit:4.12
Finally I fixed the problem by modifying build.gradle like this:
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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'
}
I've removed these lines as these will produce more errors:
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'
Also I had same problem with migrating an existing project from 2.3 to 3.0.1 and with modifying the project gradle files like this, I came up with a working solution:
build.gradle (module app)
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.mobaleghan.tablighcalendar"
minSdkVersion 16
targetSdkVersion 27
}
dependencies {
implementation 'com.android.support:appcompat-v7:25.1.0'
implementation 'com.android.support:design:25.1.0'
implementation 'com.android.support:preference-v7:25.1.0'
implementation 'com.android.support:recyclerview-v7:25.1.0'
implementation 'com.android.support:support-annotations:25.1.0'
implementation 'com.android.support:support-v4:25.1.0'
implementation 'com.android.support:cardview-v7:25.1.0'
implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
}
Top level build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
goto Android->sdk->build-tools directory make sure you have all the versions required . if not , download them . after that
goto File-->Settigs-->Build,Execution,Depoyment-->Gradle
choose use default gradle wapper (recommended)
and untick Offline work
gradle build finishes successfully for once you can change the settings
If it dosent simply solve the problem
check this link to find an appropriate support library revision
https://developer.android.com/topic/libraries/support-library/revisions
Make sure that the compile sdk and target version same as the support library version.
It is recommended maintain network connection atleast for the first time build (Remember to rebuild your project after doing this)
try this :
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
targetSdkVersion 26
}
}
compile 'com.android.support:appcompat-v7:25.1.0'
It has worked for me
I tried all of the above and nothing worked for me.
Then I followed Gradle Settings > Build Execution, Deployment > Gradle > Android Studio and checked "Disable embedded Maven repository".
Did a build with this checked and the problem was solved.
Just go to
File\Settings\Gradle. Deselect the "Offline work" box. Now you can connect and
download any necessary or missing dependencies
Your android studio may be forgot to put :
buildToolsVersion "26.0.0"
you need 'buildTools' to develop related design and java file. And if there is no any buildTools are installed in Android->sdk->build-tools directory then download first.
well got this answer from another site and don't want to take any credit for this but this solution works like butter.
Go to File\Settings\Gradle. Deselect the "Offline work" box. Now you can connect and download any necessary or missing dependencies.
This work for me. In the android\app\build.gradle file you need to specify the following
compileSdkVersion 26
buildToolsVersion "26.0.1"
and then find this
compile "com.android.support:appcompat-v7"
and make sure it says
compile "com.android.support:appcompat-v7:26.0.1"
OK It's A Wrong Approach But If You Use it Like This :
compile "com.android.support:appcompat-v7:+"
Android Studio Will Use The Last Version It Has.
In My Case Was 26.0.0alpha-1.
You Can See The Used Version In External Libraries (In The Project View).
I Tried Everything But Couldn't Use Anything Above 26.0.0alpha-1, It Seems My IP Is Blocked By Google. Any Idea? Comment
In my case, this error occur when i tried to use gridView
I resolved it by removing this line from build.grade(Module) file
implementation 'com.android.support:gridlayout-v7:28.0.0-alpha3'
This issue seems to like the following.
How to resolve repository certificate error in Gradle build
Below steps may help:
1. Add certificate to keystore-
Import some certifications into Android Studio JDK cacerts from Android Studio’s cacerts.
Android Studio’s cacerts may be located in
{your-home-directory}/.AndroidStudio3.0/system/tasks/cacerts
I used the following import command.
$ keytool -importkeystore -v -srckeystore {src cacerts} -destkeystore {dest cacerts}
2. Add modified cacert path to gradle.properties-
systemProp.javax.net.ssl.trustStore={your-android-studio-directory}\\jre\\jre\\lib\\security\\cacerts
systemProp.javax.net.ssl.trustStorePassword=changeit
Ref : https://www.cresco.co.jp/blog/entry/2014//
Try to clear cache in android studio by
File-> Invalidate cache -> invalidate
after invalidating
build-> clean project
Then you can able to build the project
this work for me
compile 'com.android.support:appcompat-v7:26.0.0'
change 26.0.0 to 26.0.1
compile 'com.android.support:appcompat-v7:26.0.1'
this work for me. add configurations.all in app/build.gradle
android {
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
}
}
I have a problem using the android support library in my Android Studio project using gradle.
If I add the support-library as dependency I will receive and "Error: Gradle: Execution failed for task ':AppName:dexDebug'.
I have done a some researches and found the problem using the support-library with other dependencies which are using the support libraries as well (greendao 1.3.0).
I would like to use a NavDrawer in my app, so I have to use these support library.
If I remove the support library, of course I will receive an inflate error for the "android.support.v4.widget.DrawerLayout".
Does somebody here has an idea?
I used two kind of dependency-imports
compile files('libs/android-support-v13.jar')
and
compile 'com.android.support:support-v4:13.0.0'
cause of a found post in a forum. But that doesn't work, too.
Thanks for your support.
Regards,
Marine
If your other dependencies also depend on the support lib, you need to make sure they are not using local dependencies (ie embedding the jar file). You should always use only
dependencies {
compile 'com.android.support:support-v4:x.y.z'
}
and not a local dependencies. Make sure all your dependencies do the same and Gradle will automatically detect that everything depends on the same library and only add it once to dex.
I tried it but I receive the dex error as well.
Attached you could see my current gradle build-file.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.0'
compile 'com.google.android.gms:play-services:3.1.36'
compile 'de.greenrobot:greendao:1.3.0'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 18
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src-gen/main/java']
}
}
}
The src-gen folder is used for my greendao generated classes.
Please let me know if you need some more information.
Edit:
I resolved it using the latest greendao version. Added: compile
de.greenrobot:greendao:1.3.1
instead of compile
de.greenrobot:greendao:1.3.0
Now it works.
Regards,
Marine_of_Hell