【发布时间】:2013-10-27 18:44:34
【问题描述】:
在 Android Studio 中运行项目失败并出现以下错误:could not find any version that matches com.android.support:appcompat-v7:+
我该如何解决这个错误?
【问题讨论】:
-
其实这是对我有用的答案:stackoverflow.com/a/18900369/1038702
在 Android Studio 中运行项目失败并出现以下错误:could not find any version that matches com.android.support:appcompat-v7:+
我该如何解决这个错误?
【问题讨论】:
从 Android Studio 转到: 工具 >> Android >> SDK 管理器
选择并安装“Extras|Android Support Repository”
【讨论】:
cordova build android 抛出了类似的错误!
对我来说,将版本从 7:27.+ 更改为 7:+ 后它工作了
【讨论】:
在 Project > app > build.gradle 文件中替换行
implementation 'com.android.support:appcompat-v7:+'29.+'
与
implementation 'com.android.support:appcompat-v7:+'
和线
implementation 'com.android.support:design:29.+'
与
implementation 'com.android.support:design:+'
然后清理构建
【讨论】:
正如How to update Android platform-tools in a headless linux?上所说的
android list sdk
android update sdk --no-ui --filter extra
【讨论】:
Filter extra not supported
这很简单。 请更新并替换 build.gradle(Project :App Name) 中的以下代码。
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
【讨论】:
aapt、javac 和 dx,它并没有太大帮助。
安装Extras|Android Support Repository 后,它对我不起作用。然后我将appbuild.gradle文件中的v7:1.6更改为v7:1.8。
com.android.support:appcompat-v7:1.8.+! 它对我有用。
【讨论】:
在您的 Android Studio 文件夹中打开 SDK Manager.exe 并安装匹配的 API。
【讨论】:
我发现所有这些答案对我来说都不正确。相反,在您的 android studio 中查看左侧下方。会有一些帮助。
例如,您会注意到
This support library should not use a different version (32) than the compilesdkVersion (23)
然后你像这样将版本更改为23
编译'com.android.support:support-v4:23'
现在,您将看到一条消息
A newer version of com.android.support-v4 than 23 is available 23.4.0.
我就是这样知道正确的版本是23.4.0
【讨论】:
如果您刚刚在 Intellij 中创建了一个新项目后看到此内容,请尝试重新创建它并选中“使用 AndroidX 工件”
【讨论】:
谁来这里同样的错误但版本 29,将您的支持库更改为版本 28:
build.gradle(app):
dependencies {
...
implementation 'com.android.support:appcompat-v7:28.+'
...
}
谷歌搜索的解决方案都不适合我。然后我看到Android 只支持最高版本 28 的库。奇怪的是我在一个开箱即用的 Android Studio 项目中遇到了这个错误。
我不确定哪个 Android Studio 版本,因为我在出错后升级了 Studio。现在在 Android Studio 3.6.3 中,带有“androidx.appcompat:appcompat:1.0.2”的新项目。
【讨论】:
这对我构建和运行这个项目很有用。 我必须在这两个部分中添加 google。
build.gradle(项目)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "29.0.2" //25.0.2"
defaultConfig {
applicationId 'com.github.nkzawa.socketio.androidchat'
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
////noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:25.0.+'
////noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:25.0.+'
implementation ('io.socket:socket.io-client:0.8.3') {
exclude group: 'org.json', module: 'json'
}
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
}
【讨论】:
遇到相同的错误,但版本为 26。
不再支持通过 SDK 管理器下载库。支持库现在可通过 Google 的 Maven 存储库获得。
解决方案:
在 buildscript/repositories 和 allprojects/repositories 中的 build.gradle (project) 添加:
maven {
url 'https://maven.google.com/'
name 'Google'
}
结果:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
它对我有用。
【讨论】: