我尝试将一个库添加到我的 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/