Cannot resolve module dependency after updating to Android Studio 3.2.1

Viewed 1145

After upgrading to AS 3.2.1, I get this gradle sync error:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :androidlib_abc.

my app gradle.build:

apply plugin: 'com.android.application'


allprojects {
    repositories {
        // The order in which you list these repositories matter.
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "de.gpx.android.rtk"
        minSdkVersion 24
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    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'
    compile project(path: ':androidlib_abc')
}

my androidlib_abc gradle.build file:

apply plugin: 'com.android.library'


android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

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

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

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

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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'
    testCompile 'junit:junit:4.12'
}

The "Open File" link in the error message points to the app gradle.build file. When I remove the line

compile project(path: ':androidlib_abc')

Then I can sync the grade project, but I cannot compile and use any package from that library (cannot resolve classes etc.)

I wish I didn't do the update... ("Never change a running system" -_-)

Any ideas how to fix?

UPDATE:

I removed the module from the project and then reimported it. Then everything worked fine! BUT: The module directory is copied into my project directory (usual behaviour). However, I need the module directory to be one level higher, in the same directory as the project directory is. This way, I could share the module with different projects without having duplicates and synchronizing work which saves me a lot of time (in fact I cannot work with multiple projects otherwise).

I used to use this settings.gradle file:

include ':app', ':androidlib_abc'

project(':androidlib_abc').projectDir = new File(rootProject.projectDir, '../androidlib_abc ')

which worked perfectly before AS 3.2.1

Now, after I successfully imported the module again and moved the module directory one level up and changed the settings.gradle file to this again, I get the unable-to-resolve-dependency error again :'-(

UPDATE2:

Using another constructor without the argument rootProject.projectDir allowed me to do the gradle sync.

include ':app', ':androidlib_abc'

project(':androidlib_abc').projectDir = new File('../androidlib_abc')

The library is finally listed on the left side!

However, a new issue came up. No classes/methods/fields etc. defined in the modul can be resolved. Not even in classes within the module itself although they are even in the same directory (package)... Cleaning and Rebuilding didn't help. Strange thing is, that building succeeds and I can apparently even install the app on my device and have it run without any exceptions...!? So is this just an IDE bug maybe?

UPDATE3

I deleted the .gradle and .idea directory and restarted AS. Everything's fine now B-)

1 Answers

try building androidlib_abc once .are you able to see this library in the side menu ?. It could be that this particular library is not imported properly

Related