【问题标题】:Failed to resolve message for support version nowhere referenced in code无法解析代码中无处引用的支持版本的消息
【发布时间】:2017-03-22 01:39:52
【问题描述】:

我已经浪费了一整天,而且离解决方案还很远。

今天早上,我决定添加 LeakCanary 来检查我们正在开发的 android 应用程序中的泄漏。我通常在离线模式下工作,因为它可以加快构建速度。将其添加为依赖项后,我禁用了离线模式。

在一分钟内我收到一条错误消息 -

Failed to resolve: com.android.support:appcompat-v7:25.0.0

目前,我们正在与 -

  1. 编译SdkVersion 23
  2. buildToolsVersion "23.0.3"

我们所有的 android 支持库,包括 v4 和 v7,都使用 23.1.1

所以我想也许 LeakCanary 库内部使用 25.0.0,所以我从 build.gradle 中删除了该库。

但错误仍然存​​在。

我试过了——

  1. 关闭并重新启动 Android Studio。
  2. 在 AS 中关闭并重新打开项目。
  3. 使缓存失效并重新启动 AS。
  4. 干净的构建。

实际上,我的代码与昨天正确构建和运行时的代码完全相同,但今天它似乎并没有运行。

可能是什么问题?

编辑

这里是 build.gradle -

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
repositories {
    maven {
        url "http://repo1.maven.org/maven2"
    }
    useLibrary 'org.apache.http.legacy'
}
defaultConfig {
    applicationId "com.example.pc.vision_test"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    multiDexEnabled true
    versionName "1.0"

}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/YouTubeAndroidPlayerApi.jar')

compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.apis:google-api-services-youtube:v3-rev149-1.20.0'
compile 'com.google.http-client:google-http-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-gson:1.20.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.android.support:multidex:1.0.1'
compile 'commons-io:commons-io:2.4'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.github.shazrazdan:Elemento:0.9.7@aar'
compile 'com.afollestad.material-dialogs:core:0.8.6.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.github.bmarrdev:android-DecoView-charting:v1.2'
compile 'com.vimeo.networking:vimeo-networking:1.0.1'
compile 'com.roomorama:caldroid:3.0.1'
compile 'org.apache:pdfbox-android:1.8.9.0'
compile 'com.android.support:customtabs:23.1.1'
}
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 你可以发布你的 gradle 吗?
  • 虽然unable to resolve com.android.support…25.0.0check 可能会对你有所帮助
  • 是的,我的问题类似。但我现在不想更新。
  • 原因是您新添加的库正在使用此库 (25.0.0)。您可以尝试使用以前版本的库,看看他们是否使用较低版本的支持库。但正确的解决方案是针对最新的SDK并支持库。
  • 我在问题中提到我删除了库,但问题仍然存在。

标签: android build.gradle


【解决方案1】:

根据我的观察,您似乎还没有将 Android SDK 平台和 Android Build Tools 更新到版本 25。 首先从 SDK Manager 下载并安装 android sdk 平台和构建工具,并在 build.gradle(module app) 中使用以下行

compileSdkVersion 25
buildToolsVersion "25.0.0"

还根据该更新依赖项。 它应该可以工作

【讨论】:

  • @YugankaSharan 尝试删除上面的文件夹,然后从目录 sdk/build-tools 中删除您想要的构建工具 23.0.3(简单来说,从 build-tools 中删除 24.xx 和 25.xx 文件夹) 同时从 SDK/Platform 中删除 android-24 & android-25。同步项目并尝试它是否有效
  • 这不是问题。我一个月前下载了android-24。而且我的 build-tools 文件夹中没有任何 25.x.x 文件夹。
猜你喜欢
  • 1970-01-01
  • 2011-02-18
  • 1970-01-01
  • 1970-01-01
  • 2011-02-28
  • 2015-11-07
  • 1970-01-01
  • 2022-07-05
  • 2020-12-31
相关资源
最近更新 更多