Home » Android » gradle – Upgraded to Android Studio 3.0: Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve project :appLib

gradle – Upgraded to Android Studio 3.0: Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve project :appLib

Posted by: admin June 15, 2020 Leave a comment

Questions:

After upgrading to Android Studio 3.0 gradle snyc fails with the following error messages:

Unable to resolve dependency for
‘:[email protected]/compileClasspath’: Could not resolve project
:SkyNavLib.

Unable to resolve dependency for
‘:[email protected]/compileClasspath’: Could not resolve
project :SkyNavLib.

Unable to resolve dependency for
‘:[email protected]/compileClasspath’: Could not resolve
project :SkyNavLib.

Unable to resolve dependency for
‘:[email protected]/compileClasspath’: Could not resolve project
:SkyNavLib.

Unable to resolve dependency for
‘:[email protected]/compileClasspath’: Could not resolve
project :SkyNavLib.

I already checked all solutions from the following link, but none worked. I also created a new project which also contains a library, and this project syncs without any problem.

Below the used build.gradle files:

For the project:

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'

}
}

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

for the App:

apply plugin: 'com.android.application'


android {
updateVersionProperties()

compileSdkVersion 26

defaultConfig {
    minSdkVersion 17
    targetSdkVersion 24
    versionCode getAndroidVersionCode()
    versionName getAndroidVersionName()
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}


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



lintOptions
        {
            abortOnError false
        }
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'net.sf.marineapi:marineapi:0.10.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation files('libs/usbserial.jar')
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 project(':SkyNavLib')
}

for the Library:

apply plugin: 'com.android.application'

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

}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
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 files('src/main/java/app/skynavigator/common/skynavlib/xml/gson-2.5.jar')
}

android {
compileSdkVersion 26

defaultConfig {
    minSdkVersion 17
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {

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


}
How to&Answers:

Your library is using the wrong plugin, it should be apply plugin: 'com.android.library' instead of apply plugin: 'com.android.application'.

Moreover you should not put the allProjects node into this build.gradle file.

new library build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 26

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.android.gms:play-services-maps:12.0.1'
    implementation 'com.google.android.gms:play-services:12.0.1'
    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 files('src/main/java/app/skynavigator/common/skynavlib/xml/gson-2.5.jar')
}