Home » Android » android – Cannot resolve symbol upon support library version change

android – Cannot resolve symbol upon support library version change

Posted by: admin June 15, 2020 Leave a comment

Questions:

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'

to

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'

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.

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.

Among the things I’ve tried:

  1. Clean / Rebuild
  2. Invalidate cache / restart
  3. Delete all the .iml files and the .idea folder
  4. Reinstalling of Android Studio, reimport of project
  5. Rebooting

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

and

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

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.

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'
}
How to&Answers:

I have finally solved:

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.

Answer:

I think I have solved this problem guys. Go to the main module in your project, it’s usually have the name app.

Then go to > Open Module Settings > in Properties change the Build Tools Version to 23.0.1.

Then to make sure open the build.gradle file, and change compileSDKVersion & buildToolsVersion to 23 and 23.0.1 respectively.

android {
compileSdkVersion 23
buildToolsVersion '23.0.1'

defaultConfig {
    applicationId "id.web.twoh"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

You should also make sure that all modules in your project have the compileSdkVersion and buildToolsVersion begin with 23, as you will use the 23th version of the support library.

Answer:

I know it’s late but I had a similar issue. It turned out that the issue was caused by the Data binding library. I had an error in the code that referenced in an invalid reference in the generated binding class. My layout file defined a webview with id webview but in the code I referenced it as webView. After correcting the error and cleaning and doing full rebuild Android Studio started recogninsing all the packages and seeing support libraries.

Answer:

I had exactly the same problem, and to solve it I have just changed the BuildDebug Configuration spinner to MainActivity :

SPINNER

Answer:

I solved my problem by changing the Run/Debug Configuration spinner to MainActivity (instead of app[androidDepedencies]) in the ToolBar…