В настоящее время я получаю сообщение об ошибке при попытке импортировать представление переработчика для моего проекта.
import android.support.v7.widget.RecyclerView;
Вот мой build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.zooapp"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.android.support:recyclerview-v7:29.0.0'
}
И вот начало моего кода:
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.recyclerview.widget.RecyclerView;
public class AnimalsHolder extends RecyclerView.ViewHolder
implements View.OnClickListener {
private final ImageView animalIcon;
private final TextView animalName;
Когда это так, и я пытаюсь нажать кнопку, чтобы открыть новое действие (где должен быть вид рециркулятора), приложение просто падает и говорит:
android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.v7.widget.RecyclerView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
Тогда, когда я удаляю androidx и добавляю импорт, который должен быть там с V7.
import android.support.v7.widget.RecyclerView;
v7 становится красным, как и расширяет RecyclerView.ViewHolder. Если я попытаюсь нажать ALT + ENTER, чтобы импортировать его снова, появится androidx.
Так как это из практики в университете, он должен быть с android .support.v7.