android - 无法解析代码中无处引用的支持版本的消息

标签 android build.gradle

我已经浪费了一整天,但离解决方案还差得很远。

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

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

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

目前,我们正在与 -

  1. 编译Sdk版本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'

最佳答案

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

compileSdkVersion 25
buildToolsVersion "25.0.0"

同时根据它更新依赖项。 那么它应该可以工作

关于android - 无法解析代码中无处引用的支持版本的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40486742/

相关文章:

android - 如何检查 wifi 网络是否受到 Android 应用程序中浏览器密码检查的保护?

java - 在触摸监听器中执行工作,然后将其委托(delegate)给前一个监听器

gradle - Gradle如何构建额外的源sourceSet?

gradle - Gradle任务中的变量$ it:引用:《 Gradle in Action》

java - Gradle构建在 list 中声明了一个新的Activity,但没有名称,从而产生了一个错误

gradle - 使用leftShift(<<)运算符时,Gradle复制任务找不到源文件

php - 将字符串传递给 PHP 文件以查询 SELECT 语句

android - 只选择一个复选框

android - Retrofit2 将图像发布为 base64

android - 无法将 Ksoap2 依赖项添加到 Android 项目