Android Studio error: cannot find symbol class AdapterViewCompat with compileSdkVersion 23 and buildToolsVersion '23.0.1'

时光毁灭记忆、已成空白 提交于 2019-12-12 18:04:48

问题


This is my gradle file and I am getting error:

cannot find symbol
import android.support.v7.internal.widget.AdapterViewCompat;
error:package AdapterViewCompat does not exist. 

Grade is as below:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'


android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'

 ...    

 dependencies 
 {
    compile 'com.android.support:cardview-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.android.support:design:23.0.0'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:gridlayout-v7:+'
    ...        
  }

回答1:


It happens because the

android.support.v7.internal.widget.AdapterViewCompat;

doesn't exist in appcompat v23 (while it existed in v22).
You can check it in

androidsdk\extras\android\m2repository\com\android\support\appcompat-v7\23.1.0\appcompat-v7-23.1.0-sources.jar

In general don't use the class inside the internal package.




回答2:


android.support.v7.internal.widget.AdapterViewCompat;

Edit

You should use buildToolsVersion "22.0.1" because of Its obsolete in 23 .




回答3:


if you have existing code then change AdapterViewCompat to AdapterView and import android.widget.AdapterView; if you are writing new code then use AdapterView instead AdapterViewcompact as AdapterViewCompact deprecated in api v23 or higher



来源:https://stackoverflow.com/questions/33609120/android-studio-error-cannot-find-symbol-class-adapterviewcompat-with-compilesdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!