Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.android.support:support-v4:26.1.0 - android

I'm using Android Studio 3.0.1. I updated Android SDK and Android tools. Also I searched and tried various solution other people tried, but none of them worked.
What should I do?
Top Level build gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app build gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.reminder"
minSdkVersion 14
targetSdkVersion 26
buildToolsVersion "26.0.2"
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
}
gradle sync screenshot

Put the following lines in gradle.properties file inside your project:
systemProp.http.proxyHost=fodev.org
systemProp.http.proxyPort=8118
systemProp.https.proxyHost=fodev.org
systemProp.https.proxyPort=8118
And also in the following file:
Windows: C:\Users\[username]\.gradle\gradle.properties
Linux: /home/[username]/.gradle/gradle.properties
And finally sync your project again.
Note: The credits goes to the author of the post in this link.

Related

Unable to resolve dependency for ':app#debug/compileClasspath':Could not resolve com.android.databinding:library:3.2.1

i am facing a problem with android studio 3.2.1 and the Gradle build version is 4.6. Recently i updated my android studio to 3.2.1 and and gradle is also updated to 4.6. If we remove the dataBinding, erors will be disappears. after adding the dataBinding its giving problem like
Unable to resolve dependency for ':app#debug/compileClasspath': Could
not resolve com.android.databinding:library:3.2.1.
Unable to resolve dependency for ':app#debug/compileClasspath': Could
not resolve com.android.databinding:adapters:3.2.1.
Unable to resolve dependency for
':app#debugAndroidTest/compileClasspath': Could not resolve
com.android.databinding:library:3.2.1.
my Gradle build of the project level is
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.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/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
is any one solved this issues please help in this case.I have tried all the trials but did not worked.
my app level gradle is
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.sample.mvvmandroidstudio"
minSdkVersion 21
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'
}
}
dataBinding {
enabled = true
}
}
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'
}
I made some edit in your gradle.
Project level
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.sample.mvvmandroidstudio"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
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'
}
Changes I made:
Removed duplicate google repo
Removed testing dependencies, as I don't think you use it.
I resolved my issue by updating my android studio to recent version.
Thanks to Khemraj for your valuable time.
This can be fixed by uncheck the offline work in settings->Build,Execution Deployment->gradle.Hope it will help for you.

Dex Error while building the project

I am getting the following error when I try to build my project. This error occurs when I was trying to add JavaMail api in my project.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.persi.eatery"
minSdkVersion 21
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'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/mailcap.default'
exclude 'META-INF/mimetypes.default'
}
defaultConfig {
multiDexEnabled true
}
}
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'
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:design:26.1.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.sun.mail:android-mail:1.6.1'
implementation 'com.sun.mail:android-activation:1.6.1'
implementation project(':library')
}
apply plugin: 'com.google.gms.google-services'
My library gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.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
}
P.S I have already tried Clean project followed by rebuild project as suggested in other answers but its still not working.Thanks in advance
Unable to merge dex
You have a dependencies conflict. Try to see your dependencies via command ./gradlew app:dependencies (Details here ). And you will see the next situation:
As you can see android-mail depends on android-activation. I think you don't need to use the line implementation 'com.sun.mail:android-activation:1.6.1'
P.S. For debugging builds you can use the next flag "--stacktrace". Then you can see more information about your issue.

Gradle build in Android Studio

I updated my Android Studio to version 3.0.1, and then Gradle to 4.2 and Android plugin tools to 3.0.1. After that whenever I create a new project it gives me the Gradle build problem.
This is my module build.gradle:
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.nasser.studio.test"
minSdkVersion 14
targetSdkVersion 27
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:27.0.3'
}
Also I unchecked the work offline for gradle.
I also checked AS settings which displays some errors:
Update 1:
When I change the compile SDK to version 25 like this, the Gradle build is completed correctly.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.nasser.studio.test"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:25.3.1'
}
But changing to latest versions (26 or 27), it gives me the same error. I also should mention that during Gradle build process for these versions, it's downloading files from Maven repositories which doesn't happen in version 25 ( I'm using a proxy connection).
Moreover, the search box of AS for support library gives me this version which is not the latest version (27.0.2).
You should use stable v7:27.0.2 instead off v7:27.0.3.
implementation "com.android.support:appcompat-v7:27.0.2"
FYI
If you are using Android Studio 3.0 or above make sure, your build.gradle (PROJECT level) file looks like this:
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
}
google()
}
}
Then Clean-Rebuild-Run.
Add this to your project level build.gradle file:
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
}
}
Change this on your Project level build.gradle
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
first, check with your gradle-wrapper.properties which should be having this
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-all.zip
and in project-level build.gradle
build script {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
also you need to change according this
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations
and see the topic Migrate dependency configurations for local modules
you will get better idea what things need to change in dependencies.

Failed to sync gradle project after adding Mapbox navigation SDK package.Its showing some irrelavant error [duplicate]

This question already has answers here:
Failed to resolve: com.android.support:cardview-v7:26.0.0 android
(26 answers)
Closed 5 years ago.
Here is my gradle file. I am using Appcompat 25.3.1 version, but the error is on Appcompat 26.1.0. This error goes off when navigation SDK package is removed. I dont understand what is happening. Any help is greatly appreciated.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.aadhilahmed.test3"
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'
}
}
}
repositories{
mavenCentral()
}
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.3.1'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.2' //error is here
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
And this is my error message:
Failed to resolve: com.android.support.appcompat-v7:26.1.0
Error:- Install repository and sync project.
Open file.
Show in Project Structure Dialog.
Even clicking on Install repository and sync project does absolutely nothing.
Add this inside your repositories block in your project level build.gradle file:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
This is the best way to do it.
In your root level gradle.build use below
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and in your gradle-wrapper.properties file change the wrapper version as below
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
also in your app level build.gradle make sure you are using 26 vesion as below
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.xxxx"
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'
}
}
}

Butterknife gradle error on Android Studio 3.0 due to android-apt plugin

After upgrading to Android Studio 3.0 I had some issues with gradle that I was able to fix checking on the developers website
However, I was not able to find how to fix the issue with the apply plugin: 'android-apt' I have tried several things such as removing it from the project gradle and add it to the app gradle as annotationProcessor 'com.neenbedankt.gradle.plugins:android-apt:1.8' . also removed the apt, etc, etc.
Anyway, Studio is complaining about it. Any help is greatly appreciated. Thanks!
// 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:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
ext {
supportLibVersion = '27.0.0'
firebaseLibVersion = '11.4.2'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
APP GRADLE
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.0"
defaultConfig {
applicationId "xxxxxxxxxxxxxxxxxxxx"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
apply plugin: 'android-apt'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${supportLibVersion}"
.....
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
Do not use apt plugin, add the dependency like this:
compile "com.jakewharton:butterknife:8.8.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
Reference
If you are in hurry you can disable that thing.
As per Document
If you are experiencing issues migrating to the new dependency
resolution strategy, you can restore behavior to that of Android
plugin 2.3.0 by setting includeCompileClasspath true. However,
restoring behavior to version 2.3.0 is not recommended.
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
}
}
And one more thing you have to define flavorDimensions "default" property in buildTypes tag in gradle file.
You can check more about this here.

Categories

Resources