支持库版本更改时无法解析符号 [英] Cannot resolve symbol upon support library version change

查看:18
本文介绍了支持库版本更改时无法解析符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能对这个问题有所了解.我正在尝试从以下位置更改支持库版本:

I'm hoping someone might shed some light on this issue. I am trying to change the support library versions from:

compile 'com.android.support:support-annotations:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-v13:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'

compile 'com.android.support:support-annotations:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'

通常看起来是一个简单的小升级让我兴奋了一整天.基本上在更新 gradle.build 文件时,我同步 -> 清理,并且在 IDE 上出现了一堆无法解析符号错误,用于支持库中的类.

What usually seems like a simple minor upgrade has caused me the entire day. Basically upon updating the gradle.build file, I sync -> clean, and there appears a bunch of Cannot Resolve Symbol errors appearing on the IDE for classes from the support library.

更有趣的是,如果我尝试通过 adb 在我的手机上运行代码,尽管 AS 显示为无法解析符号",但它在我的手机上运行良好.

What's further interesting about this is that if I try to run the code on my phone through adb, despite AS showing up as "Cannot resolve symbol", it runs perfectly fine on my phone.

其中包括我尝试过的:

  1. 清理/重建
  2. 使缓存无效/重新启动
  3. 删除所有 .iml 文件和 .idea 文件夹
  4. 重新安装 Android Studio,重新导入项目
  5. 重新启动

深入挖掘构建目录,它们在某种意义上是相似的

Digging further into the build directory, they are similar in the sense that both

build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\jars\classes.jar

build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\jars\classes.jar

build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\jars\classes.jar

build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\jars\classes.jar

分别生成.不同的是,在AS中,对于以前的版本,classes.jar"可以在AS中打开,而在新版本中,它们无法在 AS 中打开.

were generated respectively. What's different is that in AS, for the previous version, the "classes.jar" can be opened in AS where as with the new version, they cannot be opened in AS.

我觉得我已经用尽了所有可用的选项,所以如果有人能说明如何解决这个问题,我将不胜感激.

I feel that I have pretty much exhausted all available options so if anyone can shed some light on how to resolve this, I would really much appreciate it.

我的完整 gradle.build 文件:

My full gradle.build file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.XXX"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.1.1"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}



dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(path: ':XXX', configuration: 'android-endpoints')
    testCompile 'junit:junit:4.12'
    compile 'com.google.code.gson:gson:2.4'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.balysv:material-ripple:1.0.2'
    compile 'net.sf.flexjson:flexjson:3.3'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.google.android.gms:play-services-ads:8.1.0'
    compile 'com.google.android.gms:play-services-identity:8.1.0'
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
    compile 'com.android.support:support-annotations:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.android.support:support-v13:23.1.0'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
}

推荐答案

我终于解决了:

首先,我更新了gradle插件.

First of all, I updated the gradle plugin.

dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
}

然后只需构建->清理项目,一切都会再次运行.

Then just Build->Clean project and everything works again.

这篇关于支持库版本更改时无法解析符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆