8

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

Unable to resolve dependency for ':Skynavigator@debug/compileClasspath': Could not resolve project :SkyNavLib.

Unable to resolve dependency for ':Skynavigator@debugAndroidTest/compileClasspath': Could not resolve project :SkyNavLib.

Unable to resolve dependency for ':Skynavigator@debugUnitTest/compileClasspath': Could not resolve project :SkyNavLib.

Unable to resolve dependency for ':Skynavigator@release/compileClasspath': Could not resolve project :SkyNavLib.

Unable to resolve dependency for ':Skynavigator@releaseUnitTest/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'
    }
}


}
ColdFire
  • 6,764
  • 6
  • 35
  • 51
Christoph
  • 127
  • 1
  • 2
  • 8
  • please go through this https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html – krishank Tripathi Apr 09 '18 at 10:31
  • This have the similar issues pls see this https://stackoverflow.com/questions/47263668/could-not-resolve-project-cordovalib – krishank Tripathi Apr 09 '18 at 10:33
  • does the settings.gradle file contains reference to SkyNavLib? – Lino Apr 09 '18 at 11:24
  • Thanks for the tips. I already the 2 mentioned links and tried out everything proposed there, but still the same issue. The settings.gradle file also contains the SkyNavLib reference. – Christoph Apr 09 '18 at 16:17

1 Answers1

12

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')
}
xiaomi
  • 6,553
  • 3
  • 29
  • 34