use*_*r25 21 android material-components-android
SwitchMaterial
所以我在一种布局中使用:
<com.google.android.material.switchmaterial.SwitchMaterial...
Run Code Online (Sandbox Code Playgroud)
Firebase Crashlytics 向我发送垃圾邮件,其中许多用户都收到以下错误
致命异常:java.lang.RuntimeException 无法启动活动 ComponentInfo{...}:android.view.InflateException:二进制 XML 文件行 #324:二进制 XML 文件行 #324:膨胀类 com.google.android.material 时出错。 switchmaterial.SwitchMaterial
由 android.content.res.Resources$NotFoundException 引起,来自可绘制资源 ID #0x7f080047 的文件 res/drawable/abc_switch_thumb_material.xml
应用主题:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">...
Run Code Online (Sandbox Code Playgroud)
材料部:
implementation "com.google.android.material:material:1.6.1"
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
更新
我尝试使用Switch
AndroidX AppCompat 库,但仍然存在与可绘制对象相同的问题:
Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{****.ui.MainActivity}: android.view.InflateException: Binary XML file line #324: Binary XML file line #324: Error inflating class androidx.appcompat.widget.SwitchCompat
Caused by android.content.res.Resources$NotFoundException Drawable ***:drawable/abc_switch_thumb_material with resource ID #0x7f080047
这太奇怪了,虽然它在我的智能手机上运行良好,但它已经影响了我的 22 个用户
是的,我为发布版本启用了以下两个选项
minifyEnabled true
shrinkResources true
Run Code Online (Sandbox Code Playgroud)
但对于不同的应用程序来说,它一直工作得很好,而且我从来不需要向 proguard 文件中添加任何内容来保持某些第三方库(尤其是 Google 库)的可绘制性 -abc_switch_thumb_material
更新2
我只是尝试从我的 AAB 文件下载 Google Play Console 生成的 APK
我查了一下apk\res\drawable\
,发现drawable是可用的
这是魔法...
但是这个生成的 APK 是通用的,Google Play 控制台会根据设备类型及其 Android 版本生成不同的 APK,所以在这种情况下会发生什么我不知道
更新3
Switch
即使 Android Studio 显示以下警告,我也会尝试使用:
使用 AppCompat 中的 SwitchCompat 或 Material 库中的 SwitchMaterial
但至少我希望我的应用程序不会因此而对某些用户造成崩溃
发生错误的 ps 设备 (Firebase Crashlytics):
我的build.gradle
该应用程序的文件(如果它无论如何都有帮助,并且 mb 库之间存在一些冲突)
项目构建.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
kotlin_version = "1.7.10"
nav_version = "2.5.1"
hilt_version = "2.43.2"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.gms:google-services:4.3.13"
classpath "com.google.firebase:firebase-crashlytics-gradle:2.9.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" // for DataStore
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
应用程序模块build.gradle:
plugins {
id "com.android.application"
id "kotlin-android"
id "kotlin-kapt"
id "com.google.gms.google-services"
id "com.google.firebase.crashlytics"
id "kotlin-parcelize"
id "dagger.hilt.android.plugin"
id "androidx.navigation.safeargs.kotlin"
id "kotlinx-serialization" // for DataStore
}
android {
compileSdkVersion 32
defaultConfig {
applicationId ***
minSdkVersion 21
targetSdkVersion 32
multiDexEnabled true
versionCode 18
versionName "1.0.15"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
manifestPlaceholders = [crashlyticsEnabled: false]
signingConfig signingConfigs.release
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
manifestPlaceholders = [crashlyticsEnabled: true]
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
}
buildFeatures {
dataBinding = true
}
}
dependencies {
implementation "androidx.core:core-ktx:1.8.0"
implementation "androidx.appcompat:appcompat:1.5.0"
implementation "androidx.activity:activity-ktx:1.5.1"
implementation "androidx.fragment:fragment-ktx:1.5.2"
implementation "androidx.multidex:multidex:2.0.1"
implementation "com.google.android.material:material:1.6.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "com.jakewharton.timber:timber:5.0.1"
implementation platform("com.google.firebase:firebase-bom:30.3.2")
implementation "com.google.firebase:firebase-analytics"
implementation "com.google.firebase:firebase-crashlytics"
implementation "com.google.firebase:firebase-ads:21.1.0"
implementation "com.google.android.ump:user-messaging-platform:2.0.0"
implementation "com.android.billingclient:billing-ktx:5.0.0"
def lifecycle_version = "2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
// Hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
// OkHttp
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.0"))
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")
// Retrofit
def retrofit = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit"
implementation "com.squareup.retrofit2:converter-gson:$retrofit"
// Glide
def glide_version = "4.13.2"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
// Pagination
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
// Datastore
implementation "androidx.datastore:datastore:1.0.0"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.4.0"
implementation "org.jsoup:jsoup:1.15.2"
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2687 次 |
最近记录: |