android - 尝试在 android studio 中添加库时出现 compileClassPAth 错误

标签 android gradle

我尝试将一个库添加到我的 android studio 项目中,但它给了我以下错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :libraries:MultipleImagePick-master.


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :libraries:MultipleImagePick-master.


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :libraries:MultipleImagePick-master.


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :libraries:MultipleImagePick-master.



Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :libraries:MultipleImagePick-master.

我基本上在我的项目中创建了一个名为“库”的目录,并粘贴了名为 MultipleImagePick-master 的库。

然后我将其包含在我的设置 gradle 中:

include ':libraries:MultipleImagePick-master'

然后我在项目中为此添加了依赖模块,当它尝试进行构建时我遇到了那些失败。以下是我的 gradle.build 文件:

应用程序构建:

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 27
        defaultConfig {
            applicationId "com.mima.iloveyou"
            minSdkVersion 15
            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'
            }
        }
    }

    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.2'
        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'
    implementation project(':libraries:MultipleImagePick-master')
}

项目渐变构建:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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


        // 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
}

最佳答案

将ConstraintLayout库的版本设置回1.1.1

    implementation 'com.android.support.constraint:constraint-layout:1.1.1'

关于android - 尝试在 android studio 中添加库时出现 compileClassPAth 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50981608/

相关文章:

android - 字符串资源 ID 值是否保证在不同项目中保持一致?

gradle - 如何通过独立插件将类文件添加到Gradle源集中?

gradle - 如何访问文件复制过滤器任务中的行号?

java - Android - 套接字超时

android - Android 8.0 缺少通知样式

Android Studio 3.0 任务 : unable to merge dex 执行失败

android - 在 Android Studio 中为 OpenCv 库启用 Gradle 缩小

php - 从数据库插入或选择数据时 PHP 出错

java - 更新 gradle 包装文件会产生不同的结果

android - Android Studio Gradle错误