芯片材料组件崩溃
我正在使用com.android.support:appcompat-v7:28.0.0支持库使用android.support.design.chip.Chip材料元素。应用程序因以下错误而崩溃:
Caused by: android.view.InflateException: Binary XML file line #130: Binary XML file line #130: Error inflating class com.google.android.material.chip.Chip
Caused by: android.view.InflateException: Binary XML file line #130: Error inflating class com.google.android.material.chip.Chip
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.material.chip.Chip" on path: DexPathList[[zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/base.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_resources_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
我已经尝试使用this solution,并用以下内容替换了我的主题父项:
Theme.MaterialComponents.NoActionBar
Theme.MaterialComponents.Light.NoActionBar
Theme.MaterialComponents.Light.Bridge
但仍然会崩溃。我也迁移到AndroidX,但仍然没有机会。 应用程式Gradle档案:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.m22_3.pilotapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 6
versionName "2.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
implementation 'com.github.florent37:expansionpanel:1.0.0'
implementation 'com.airbnb.android:lottie:2.5.5'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
implementation 'com.fasterxml.jackson.core:jackson-core:2.8.9'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.9'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.9'
implementation 'org.glassfish:javax.annotation:10.0-b28'
implementation 'com.github.bumptech.glide:glide:4.6.1'
}
项目的gradle文件:
buildscript {
repositories {
maven { url 'https://jitpack.io' } //https://jitpack.io or https://maven.google.com
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://jitpack.io'
}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
XML代码:
<CoodrdinateLayout>....<LinearLayout>.... <com.google.android.material.appbar.AppBarLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="@color/transparent">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:measureAllChildren="false"
android:scrollbars="none">
<LinearLayout
android:id="@+id/filter_linear_layout_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/cornered2_stroked_tab2color"
android:orientation="horizontal"
android:padding="5dp">
<com.google.android.material.chip.Chip
android:id="@+id/filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/cornered_filled_tab2color"
android:padding="4dp"
android:text="@string/filter"
android:textColor="@color/white"
app:chipIcon="@drawable/filter"
app:closeIconEnabled="false"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="@+id/location_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="@+id/experience_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="@+id/timeInterval_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="@+id/industry_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="@+id/partFullTime_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="@+id/blueWhiteCollar_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:closeIconEnabled="true"
app:singleLine="true" />
</LinearLayout>
</HorizontalScrollView>
</com.google.android.material.appbar.AppBarLayout>
如果有人可以提供帮助,将不胜感激。