我是Android Studio的新手,我竭尽全力解决此问题“无法解决:com.android.support:appcompat-v7:28.+”
我试图清理项目,使现金/重新启动无效,并删除.idea并保持不变
出于学习原因,我正在使用android studio 2.2.1,并将其更新为android studio 3,并且出现了多个渲染问题,因此我返回了2.2.1版。
我尝试添加
行家{
网址'https://maven.google.com/'
名称为“ Google”
}
所以,它遇到了另一个问题
"Error:Execution failed for task ':app:processDebugResources'.
> Error: more than one library with package name 'android.support.graphics.drawable'"
最后,我尝试将“ appcompat-v7:28. +”更改为“ appcompat-v7:27”,它可以正常工作,但仍然告诉我应该使用相同的库以避免错误
这是我的Gradle代码:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.1"
defaultConfig {
applicationId "com.example.aimlive.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:28.+'
testCompile 'junit:junit:4.12'
}
答案 0 :(得分:5)
尝试将其添加到您的代码中:
repositories {
jcenter()
maven { // <-- Add this
url 'https://maven.google.com/'
}
}
更新:现在您转到了另一个错误:
错误:多个库的软件包名称为'android.support.graphics.drawable ...
要解决此问题,您需要在compile
部分将implementation
更改为dependencies
。
答案 1 :(得分:3)
如果您正在使用
compileSdkVersion 28
在代码下方添加依赖项
implementation 'com.android.support:appcompat-v7:28.0.0-alpha'
这是link
答案 2 :(得分:3)
将'com.android.support:appcompat-v7:28+'
替换为'com.android.support:appcompat-v7:28.0.0'
并在下面添加依赖项
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
答案 3 :(得分:1)
尝试一下,希望它能正常工作
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design: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'
依赖项
classpath 'com.android.tools.build:gradle:3.1.4'
android
compileSdkVersion 28
minSdkVersion 21
targetSdkVersion 28
答案 4 :(得分:0)
尝试使用此代码,希望它会起作用。谢谢
build.gradle(项目)
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
build.gradle(应用程序)
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "YOUR_PACKAGE_NAME"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
依赖关系检查实施情况
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
答案 5 :(得分:0)
我发现'com.android.support:animated-vector-drawable'和'com.android.support:support-vector-drawable'在支持库版本28.0.0中具有相同的包名称。通常,这不会造成问题。
但是如果gradle.properties中包含以下行
android.uniquePackageNames = true
您会看到错误
more than one library with package name 'android.support.graphics.drawable'"
如果您应该使用uniquePackageNames选项,请使用androidx而不是支持库28.0.0。
答案 6 :(得分:0)
In case someone like me stuck for hours and find out the you have to check the maven dependency "com.android.support:appcompat-v7:28.0.0". remove the "+" sign as gradle does not like it for unpredictable versions. so i had to check the maven repository and found that i was compiling with 29 and 29 does not exist. please check below link
[""][1]
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.amirkhan.birthday"
minSdkVersion 15
targetSdkVersion 28
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 'com.android.support:appcompat-v7:28.0.0'
}
2)) Maven should be included.
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}
Wallah the problem is solved
[1]: https://mvnrepository.com/artifact/com.android.support/appcompat-v7/28.0.0