我想用
SwitchMaterial
Android项目中的组件,但是Android studio在设计时找不到它,并且将它包含在我的xml布局中会导致
ClassNotFoundException
在运行时。
'com.google.android.material:material:1.0.0'
是在我的依赖关系和梯度同步没有错误
还有一些其他的材料成分(如我正在使用的)
MaterialButton
在同一个XML/活动上
com.google.android.material.switchmaterial.SwitchMaterial
xml格式
无法导入
尝试添加到活动java单元时
没有预先保护规则设置,所以不应该弄乱它
找不到
开关材料
即使有其他组件
应用程序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'
}
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" />
如有任何帮助,我们将不胜感激。我不明白为什么会有组件丢失。