175

I migrate to Android studio 3.0. So, the project become unable to compile a module named ":animator" and it displays me this error:

 Error:Unable to resolve dependency for
 ':app@dexOptions/compileClasspath': Could not resolve project
 :animators. <a
 href="openFile:/home/mobilepowered/MobilePowered/MyInnovalee/trunk17-10-2017/app/build.gradle">Open
 File</a><br><a href="Unable to resolve dependency for
 &#39;:app@dexOptions/compileClasspath&#39;: Could not resolve project
 :animators.">Show Details</a>

and show details gives this log :

 Unable to resolve dependency for ':app@dexOptions/compileClasspath':
 Could not resolve project :animators.

 Could not resolve project :animators. Required by:
     project :app
 Unable to find a matching configuration of project :animators:
      - Configuration 'debugApiElements':
          - Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' and found incompatible value 'debug'.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and
 found compatible value 'Aar'.
          - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but
 wasn't required.
          - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
      - Configuration 'debugRuntimeElements':
          - Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' and found incompatible value 'debug'.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and
 found compatible value 'Aar'.
          - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but
 wasn't required.
          - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
      - Configuration 'releaseApiElements':
          - Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' and found incompatible value 'release'.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and
 found compatible value 'Aar'.
          - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but
 wasn't required.
          - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
      - Configuration 'releaseRuntimeElements':
          - Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' and found incompatible value 'release'.
          - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and
 found compatible value 'Aar'.
          - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but
 wasn't required.
          - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
Vikrant Kashyap
  • 6,398
  • 3
  • 32
  • 52
Imene Noomene
  • 3,035
  • 5
  • 18
  • 34
  • what have you done? – Pandiri Deepak Oct 27 '17 at 07:05
  • As first and temporary solution to make the project run with android studio 3.0 , I maintain **distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip** , **compileSdkVersion 25** and **buildToolsVersion "25.0.3"** and **classpath 'com.android.tools.build:gradle:2.3.3'** – Imene Noomene Oct 27 '17 at 08:14
  • @ImeneNoomene, JackHuang´s answer should be the chosen answer. It is based on official documentation, and what Sackurise says is not always doable (think React Native projects where most of your modules come from the Web) – Leo supports Monica Cellio Sep 24 '18 at 19:23
  • I encounter this issue due to multi flavor library. Solved from: https://stackoverflow.com/a/48718124/1099884 – Yeung Dec 24 '18 at 05:02
  • I resolved my issue by simply updating `Android Studio` – Frank Goortani Apr 02 '19 at 01:06

32 Answers32

151

With Android Studio 2.3(AS) the project works fine and i can able to run the App. After updating the AS to Android Studio 3.0. i too got the error as below for libraries and build types.

Unable to resolve dependency for ':app@dexOptions/compileClasspath': Could not resolve project : library_Name.

Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project : library_Name.

To Solve the issue, simply.

What ever the

buildTypes{
          debug{ ... }
          release{ ... }
    }

you have in your (app) build.gradle file, You have to include all the buildTypes{ } with same names as like

buildTypes{
      debug{ ... }
      release{ ... }
}

in to build.gradle files of All libraries/modules included in project.

clean and rebuild the project, the issue will be fixed.

Still issue not fixed, update the gradle-wrapper.properties to

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Sackurise
  • 2,804
  • 1
  • 18
  • 18
  • That did the trick, although, there is at least one incompatibility with copying the buildTypes as they are. If you copy the applicationIdSuffix parameter, it will tell you that it is not possible to have them in the dependency. – xarlymg89 Mar 01 '18 at 16:40
  • 113
    Include all the `buildTypes { }` with the same names? What are you talking about? – lolololol ol Mar 13 '18 at 17:02
  • 13
    I also don't know what this means. – Sir Neuman Apr 11 '18 at 16:18
  • 7
    https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#variant_dependencies Unfortunately, this no longer works for modern builds – mochadwi Apr 12 '18 at 03:22
  • 3
    as much as this makes sense this is not a useful answer... I do not want to add this build type to all my modules.. they have absolutely no business being anywhere except my app! and my app needs to know what is the fallback build type it needs to take it's configuration from! – TacB0sS Apr 12 '18 at 20:22
  • can you explain more, please? – Nima.S-H May 31 '18 at 23:56
  • @lololololol, he says that into library's `build.gradle` you should add the same two branches as in app's `build.gradle`: `build` and `release` with all their interiors (minifyEnabled, proguardFiles, etc). – CoolMind Sep 10 '18 at 09:51
  • 3
    This is a solution, it's just a workaround. The @JackHang answer's is the correct way to handle this problem (https://stackoverflow.com/a/47029361/6600000) – Keivan Esbati Oct 13 '18 at 09:13
  • Does not work, I already had the same build types in both, Gradle 5.1.1 – m0skit0 May 22 '19 at 14:39
  • Check flavors and add missingDimensionStrategy – Ravin Jul 24 '19 at 22:13
  • Confirm whether you have imported a Library project as a module, not imported an Application project as a module into the app. Because when you import the Application project as a module. you land into the above error. – Logo Feb 27 '20 at 05:28
  • I have created a Library Project and I uploaded it to Jitpack and now I am using it in another project using implementation 'link to the library' but I am getting the error - :app@debug/compileClasspath': Could not resolve libraryProject. When I am using it in another project it is not giving any error. What could be the problem? – Aman Verma May 04 '20 at 04:09
130

As stated in the official migration guide, this error is encountered when:

Your app includes a build type that a library dependency does not

android {
  buildTypes {
      release {
          ...
      }
      dexOptions {
          ...
        // release & debug is in project animators
        matchingFallbacks = ['release', 'debug']
      }
      debug {
          ...
      }
    }
}

Correct place to find the info is now this documentation

Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
JackHang
  • 1,309
  • 1
  • 7
  • 3
  • 18
    This should be the right answer as explained in the official migration guide. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#resolve_matching_errors – griable Feb 07 '18 at 10:26
  • 3
    this is the best answer and it has resolved my issue i just needed to use matchingFallbacks = ['release', 'debug'] in Flavors instead – Poorya Jul 10 '18 at 04:45
  • 1
    Gradle 5.1.1. Unfortunately does not work, the error is still the same. I already have the same buildTypes on the library and added matchingFallbacks to flavors to no avail. – m0skit0 May 22 '19 at 14:42
95

Make sure you're in your project

  1. Open the Preferences, by clicking File > Settings (on Mac, Android Studio > Preferences).
  2. In the left pane, click Build, Execution, Deployment >> Gradle.
  3. Uncheck/disable the Offline work checkbox.
  4. Click Apply or OK.
Beyondo
  • 2,952
  • 1
  • 17
  • 42
75

I spent a lot of time on this issue and none of above solutions work for me. The names and number of build types were also exactly equal in both app and library project.

The only mistake I was making was - In library project's build.gradle, I was using line

apply plugin: 'com.android.application'

While this line should be -

apply plugin: 'com.android.library'

After making this change, this error got resolved.

Anuj Garg
  • 959
  • 10
  • 12
  • 10
    Fantastic! This was my issue. Should be noted that applicationId in defaultConfig { } needs to be removed in the library too. – ObjectType Aug 06 '18 at 06:35
  • 1
    I was just about to post this answer, which I discovered after, like you, hard frustrating work and trying all kinds of options, and then some. [Before posting,] I decided to see the latest post on this and ..voila! This answer needs to be prioritized somehow. – nat101 Aug 14 '18 at 21:32
  • Love you bro :* – Sumit Kumar Mar 10 '19 at 13:57
  • Thanks, This is it. – Musketyr Mar 22 '19 at 13:08
  • does not work for me. and also none of the above don't work – philtz Apr 25 '19 at 00:49
  • Looks like it's not that simple. My main module apply plugin: 'com.android.application' relies on another base module which have to be apply plugin: 'com.android.application' as well. So the problem is that in one project cannot be two modules those are declarated as applications – murt May 10 '19 at 14:38
66

Modify all

compile project(':library:yourproject')

to

implementation project(path: ':library:yourproject', configuration:'default')

in your app build.gradle. Note the line with configuration.

ZooMagic
  • 616
  • 7
  • 15
Duy Phan
  • 783
  • 6
  • 5
35

I tried everything from unchecking offline work to matchingFallbacks. But nothing worked.

Then, in dependencies of app.gradle,

instead of

implementation project(':lib-name')

I used,

implementation project(path:':lib-name', configuration: 'default')

Eg: implementation project(path:':myService', configuration: 'default')

And it worked like a charm. :)

I was adding a dependency module with service and am not making a library as its a part of AOSP project.

Just in case, it helps someone.

Shachi
  • 1,858
  • 3
  • 23
  • 41
17

Solution:

Dowload the ultimate version of Gradle

http://services.gradle.org/distributions/

gradle-4.x-rc-1-all.zip.sha256 09-Jan-2018 01:15 +0000 64.00B

Unzip the distribution

Go to Android Studio -> File -> Settings -> Gradle -> Use local gradle distribution Search the file and OK

In the gradle:app write this, implementation(path: ':animators', configuration: 'default')

dependencies {
   .
   .
   .


    implementation project(path: ':animators', configuration: 'default')


}
Chris
  • 5,109
  • 3
  • 19
  • 40
Ignacio_aa
  • 318
  • 2
  • 8
  • i also had this problem. But what is the difference between `implementation project(path: ':animators', configuration: 'default')` and `implementation project(path: ':animators')` (this generate androidstudio but not work) – Andreas Jul 26 '18 at 06:04
10

Here is how I solved my problem:

instead of

compile project(':library_name')
compile project(':library_name')

in app gradle I have used

implementation project(':library_name')
implementation project(':library_name')

And in my build types for example

demoTest {
 .........
}

I added this line

demoTest {
   matchingFallbacks = ['debug', 'release']
}
Kostek
  • 283
  • 3
  • 10
Anik Dey
  • 616
  • 8
  • 17
7

I had the same issue, and solved it by adding 'mavenCentral()' to build.gradle(Project)

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}
Maybelle Pacate
  • 481
  • 7
  • 5
7

My problem is below

Unable to resolve dependency for ':app@debug/compileClasspath': Could not download rxjava.jar (io.reactivex.rxjava2:rxjava:2.2.2)

Solved by checking Enable embedded Maven Repository

enter image description here

duyuanchao
  • 3,863
  • 1
  • 25
  • 16
5

Even, I have faced the same issue.

I have fixed the issue by referring the above Solution 2 with the new g‌​radle-4.1 :

I have done the following gradle changes. It seems downloading resources through maven Amazon helped me to fix the issue, there are issues with appcompat library. Check and ensure that appcompat compatible support libraries downloaded in your system. What I feel, it just simply the resources not downloaded through maven, causing the compile error issue. Ensure the resources are found in your local drive to fix the issue.

Just Played around with

  1. Maven Amazon url
repositories {
    maven {
        url "https://s3.amazonaws.com/repo.commonsware.com"
    }
    jcenter()
}
  1. Compatible support libraries downloaded in the drive and referring compatible libraries in gradle.
dependencies {
    implementation fileTree(dir: 'libs', include: \['*.jar'\])
    implementation 'com.android.support:appcompat-v7:26.0.0-alpha1'
    implementation  'com.android.support:support-v4:26.0.0-alpha1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

}

Complete file

        apply plugin: 'com.android.application'

        repositories {
            maven {
                url "https://s3.amazonaws.com/repo.commonsware.com"
            }
            jcenter()
        }

        android {
            compileSdkVersion 26
            defaultConfig {
                applicationId "com.cognizant.interviewquestions.cognizantiqpractice2"
                minSdkVersion 18
                targetSdkVersion 26
                versionCode 1
                versionName "1.0"

                javaCompileOptions {
                    annotationProcessorOptions {
                        includeCompileClasspath false
                    }
                }

                dexOptions {
                    javaMaxHeapSize "4g"
                    preDexLibraries = false
                }
            }

            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.0.0-alpha1'
            implementation  'com.android.support:support-v4:26.0.0-alpha1'
            implementation 'com.android.support.constraint:constraint-layout:1.0.2'

        }
---------------------------------------------------------------------------

enter image description here

enter image description here

A.L
  • 10,259
  • 10
  • 67
  • 98
Arvind Anandala
  • 539
  • 2
  • 7
  • 15
5

Change this code in gradle:

  compile project(':yourLibrary')

to

   implementation project(path: ': yourLibrary', configuration:'default')
Maryam Azhdari
  • 1,161
  • 11
  • 8
4

I found two type of solutions :

  1. Solution with the old g‌​radle-3.3 :

    As first and temporary solution to make the project run with android studio 3.0 , I maintain the old config of my previous of Android Studio 2.3

    distributionUrl=https://services.gradle.org/distributions/g‌​radle-3.3-all.zip , compileSdkVersion 25** and **buildToolsVersion "25.0.3" and classpath 'com.android.tools.build:gradle:2.3.3

  2. Solution with the new g‌​radle-4.1 :

    To work with the new features of gradle 4.1 and the classpath com.android.tools.build:gradle:3.0.0' , I followed this link https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html . So, Those are my implementations :

In the file 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

In the file build.gradle of the project :

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        //classpath 'me.tatarka:gradle-retrolambda:3.3.1' remove this line
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

In the file build.gradle of the app :

apply plugin: 'com.android.application'
//apply plugin: 'me.tatarka.retrolambda' remove this line

repositories {
    maven {
        url "https://s3.amazonaws.com/repo.commonsware.com"
    }
    jcenter()
    mavenCentral()
    maven { url "https://jitpack.io" }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.imennmn.myprojectid"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        /**
         * Enabling multidex support.
         */
        multiDexEnabled true
        missingDimensionStrategy 'minApi' , 'minApi24'

        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }

        dexOptions {
            javaMaxHeapSize "4g"
            preDexLibraries = false
        }

    }
    buildTypes {
        release {
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }

    /**
     * Solve the problem when using multiple free source libs
     * NOTICE or LICENSE files cause duplicates
     */
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/DEPENDENCIES'
        //exclude duplicate butterknife and parceler libs
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/rxjava.properties'

    }


}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation files('libs/motwin-android-sdk-3.2.0-RELEASE-TLS.jar')
    implementation files('libs/notifmanager-android-lib-3.1.0-RELEASE.jar')
    implementation files('libs/commons-lang-2.4.jar')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:26.0.2'
    implementation 'com.android.support:support-v4:26.0.2'
    implementation 'com.android.support:design:26.0.2'
    implementation 'com.android.support:multidex:1.0.2'
    api 'com.jakewharton:butterknife:7.0.1'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.android.support:percent:26.0.2'
    implementation 'com.google.android.gms:play-services-maps:11.4.2'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.google.code.gson:gson:2.8.1'
    testImplementation 'junit:junit:4.12'
    implementation 'com.facebook.rebound:rebound:0.3.8'
    implementation 'com.google.android.gms:play-services-gcm:11.4.2'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

    implementation project(':animators')

    // Retrofit2 & XmlConverter
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

    implementation('com.squareup.retrofit2:converter-simplexml:2.3.0') {
        exclude group: 'xpp3', module: 'xpp3'
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'stax', module: 'stax'
    }

    implementation 'com.squareup.okhttp3:okhttp:3.4.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'

    //Library to reports crash
    implementation('ch.acra:acra:4.5.0') {
        exclude group: 'org.json'
    }

    implementation 'com.github.kenglxn.QRGen:android:2.3.0'

}

In the build.gradle of the library animator I upgrade targetSdkVersion to 26 :

apply plugin: 'com.android.library'

android {
  compileSdkVersion 26
  buildToolsVersion '26.0.2'

  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
  }
}

dependencies {
  implementation "com.android.support:support-compat:26.0.2"
  implementation "com.android.support:support-core-ui:26.0.2"
  implementation "com.android.support:recyclerview-v7:26.0.2"
}
Vikrant Kashyap
  • 6,398
  • 3
  • 32
  • 52
Imene Noomene
  • 3,035
  • 5
  • 18
  • 34
3

you just need to reset dependencies in app.gradle file like old one as

androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'

to new one as

androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
Wasif Ali
  • 227
  • 2
  • 6
3

Make sure you have disabled "Offline work" in Gradle settings (Setting->Build, Execution, Deployment->Build Tools->Gradle).

I made this mistake. I followed a guide on speeding up gradle builds and had turned on the Offline work option. If that is enabled, Gradle won't be able to download any new dependencies and hence will result in the "Unable to resolve dependency" error.

Yashas
  • 809
  • 8
  • 16
2

I met the same problems and has solved.

Due to my situation, I guess your build.gradle file for app project contains snippets below:

android {
    ...
    buildTypes {
        debug {...}
        release {...}
        dexOptions {...}
    }
}

but actually, dexOptions is not a build type, you should move dexOptions section out buildTypes, like this:

android {
    ...
    dexOptions {
        ...
    }

    buildTypes {
        debug {...}
        release {...}
    }
}

Hope that can help someone.

Zhuang Ma
  • 614
  • 7
  • 12
2

Adding productFlavors{} to the app build.gradle solved the issue for me. See below:

buildTypes {
        release {
             ...
        }
    }
productFlavors {
    }
cbelwal
  • 379
  • 2
  • 7
2

This may also happen when you add a reference to the feature module that uses the incorrect plugin type. Simply change com.android.application to com.android.feature or com.android.library

https://i.stack.imgur.com/NDjnG.png

Igor
  • 2,039
  • 23
  • 27
1

I think it's from gradle-wrapper.properties file : make distribution url distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip and do not upgarde to : distributionUrl=https\://services.gradle.org/distributions/gradle-4 ....

Nawrez
  • 3,314
  • 8
  • 28
  • 42
  • Yes , wha't your encoutred problem if it didn't ? – Nawrez Oct 27 '17 at 07:46
  • 2
    Did not work for me. This solution gives me an error "Error:(1, 0) Minimum supported Gradle version is 4.1. Current version is 3.3. Please fix the project's Gradle settings. Fix Gradle wrapper and re-import project" – sa_penguin Nov 16 '17 at 15:36
  • 3
    Not upgrading is not a valid solution to this problem. – Mark Feb 22 '18 at 17:29
1

It seems like it's a bug on Gradle. This solves the problem for me, but it's not a solution. We have to wait for a new version fixing this problems.

On build.gradle in the project set classpath 'com.android.tools.build:gradle:2.3.3' instead classpath 'com.android.tools.build:gradle:3.0.0'.

On gradle-wrapper.properties set https://services.gradle.org/distributions/gradle-3.3-all.zip instead https://services.gradle.org/distributions/gradle-4.1.2-all.zip

Ramin
  • 78
  • 1
  • 10
1

In my case, the problem I had was due to a dependency I was trying to import (BottomNavigationViewEx).

This dependency requires to be downloaded from jitpack.io and maven.google.com, and I was putting this config in buildscript section:

buildscript {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" } // this is incorrect
        maven { url "https://maven.google.com" } // this is incorrect
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    } 
}

which it was incorrect, I need to remove these two maven lines and include them in the right section, 'allprojects':

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

Hope it helps somebody as same for me.

Neonigma
  • 1,825
  • 17
  • 20
1

I tried all the solutions given above and none of them worked for me, I ensured that I have exact build types and product flavours in my library module and app module.

Jerry Okafor
  • 3,710
  • 3
  • 17
  • 26
1

This thread seems to have wondered a bit, however as relating to the original question, not only do you have to have your buildTypes in both build.gradle files, you need to have your productFlavors (if you are using them of course) in both build.gradle files as well.

user330844
  • 872
  • 1
  • 12
  • 12
0

I tried running Android studio 3.0.1 with internet connection. Android studio started downloading something from a link automatically which was showing in Gradle build notification. I can't say this is a sure answer but try this out.. maybe you can get your issue resolved.

  • There are other answers that provide the OP's question, and they were posted some time ago. When posting an answer [see: How do I write a good answer?](https://stackoverflow.com/help/how-to-answer), please make sure you add either a new solution, or a substantially better explanation, especially when answering older questions. – help-info.de Nov 07 '19 at 15:21
0

If using Android Studio on Linux:

go to: Home/Android Studio Projects folder/App name folder open terminal on that page and type:

./gradlew -Dhttp.proxyHost

check if JAVA_HOME is set on valid directory, if not set valid location finally rebuild your project.

NOTE: if that doesn't work remove gradle cache folder or all of that and download again with Android Studio.

Fazel
  • 23
  • 6
0

Add the library from File->Right click->New->Module->Import Eclipse ADT project->brows your library->finish Now add in the app gradle setting following code:

implementation project(':library')

Finally add in the setting gradle following code:

include ':app', ':library'
Soumen Das
  • 1,292
  • 17
  • 12
0

After updating android studio to 3.3. I faced this problem when I tried to load Firebase JobDispatcher. Adding this link on gradle.properties solved my problem

distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
Shaon
  • 2,496
  • 26
  • 27
0

I know none of the above solutions is gonna work as I have remained stuck into this sort of issue a long time, finally resolved this issue after watching the issue very carefully, which is pointing that

Unable to resolve dependency for ':app@dexOptions/compileClasspath': Could not resolve project : library_Name.

You need to make a sure and double check if the class is residing there. This one thing will prove much helpful to many I guess because focusing on this point took me much closer to the solution. Now if nothing exists in that folder path you need to get the whole stuff like src folder build folder etc everything, copy that and paste it over there sync/rebuild project, if needed try invalidate and restart android studio. Hope so this will get you out of trouble as happend in my case.

Thanks

Ali Nawaz
  • 2,016
  • 20
  • 30
0

changing implementation 'com.android.support:appcompat-v7:27+' to implementation 'com.android.support:appcompat-v7:+' worked for me

I am using Intellij 2019 CE, with Kotlin

tausif
  • 672
  • 1
  • 6
  • 15
0

In my case it was so:

Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform artifact....

I tried ten solutions, no one worked, thus my solution was to remove C:\Users\djdance.gradle\caches and restart AS

djdance
  • 3,110
  • 27
  • 33
-1
Step 1:
1.Open the Preferences, by clicking File > Settings (on Mac, Android Studio > Preferences).
2.In the left pane, click Build, Execution, Deployment >> Gradle.
3.Uncheck/disable the Offline work checkbox.
4.Click Apply or OK.

Step 2:
downgrade the gradle-wrapper.properties content which you can access this 
file directory by clicking on CTRL + SHFT +R KEY 
e.g from
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

to 
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip

or to any lower version like /gradle-3.9-all.zip or /gradle-3.8-all.zip
Alabi Temitope
  • 405
  • 5
  • 16
-3

Try this I already fix my problem after all by commenting the lines below

dependencies

{

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//compileOnly 'com.android.support.test:runner:1.0.1'
//compileOnly 'com.android.support.test.espresso:espresso-core:3.0.1'
//androidTestImplementation 'junit:junit:4.12'

}