Я пытаюсь использовать компонент SwitchMaterial
в проекте Android, однако Android Studio не может найти его во время разработки, и включение его в мои макеты xml приводит к ClassNotFoundException
во время выполнения.
- Последний Android-проект студии, поэтому он уже настроен с использованием AndroidX
'com.google.android.material:material:1.0.0'
, находится в моих зависимостях и синхронизируется без ошибок - Некоторые другие компоненты Material присутствуютНапример, я использую
MaterialButton
в том же XML / Activity - Невозможно найти
com.google.android.material.switchmaterial.SwitchMaterial
в xml - Невозможно импортировать
com.google.android.material.switchmaterial.SwitchMaterial
при попытке добавить в модуль активности Java - Настройки сборки: Compile SDK = 29 Build Tools = 29.0.2 Min SDK = 19 Target SDK = 29
- Настройка правил Proguard не установлена (вообще), поэтому не стоит с ней связываться
- Потратил час, гугляя ответы - ничего на SO или в Документах для Android / Материалов
Не могу найти SwitchMaterial
, хотя другие компоненты есть ![Missing Components](https://key.digital/stackoverflow/material-switch-missing.jpg)
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "my.app.id"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "0.0.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "6g"
}
lintOptions {
lintConfig file("lint.xml")
showAll false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.github.bumptech.glide:glide:4.10.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.code.gson:gson:2.8.6'
}
XML-макет
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/login_notificationsSwitchFamily"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_10"
android:checked="true"
android:text="Family Friendly"
android:textSize="@dimen/textSize_16" />
Любая помощь приветствуется. Я не понимаю, почему будут отсутствовать компоненты.