问题
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