Исключения, связанные с CoreComponentFactory и предварительными условиями в Android 12 или ниже, только в релизной версиAndroid

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Исключения, связанные с CoreComponentFactory и предварительными условиями в Android 12 или ниже, только в релизной верси

Сообщение Anonymous »

Я получаю следующее исключение только в Android 12 и более ранних версиях, если оно находится в выпуске (отладка работает нормально) — исключение возникает во время выполнения, когда приложение открывается:

Код: Выделить всё

Unable to instantiate appComponentFactory
java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory"  on path: DexPathList[[zip file "/data/app/~~iaVUd900SBAkCvdX52zU5w==/com.quare.blitzsplit-b_5H-WForkfoIt1bmmzx_A==/base.apk"],nativeLibraryDirectories=[/data/app/~~iaVUd900SBAkCvdX52zU5w==/com.quare.blitzsplit-b_5H-WForkfoIt1bmmzx_A==/lib/arm64, /data/app/~~iaVUd900SBAkCvdX52zU5w==/com.quare.blitzsplit-b_5H-WForkfoIt1bmmzx_A==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.LoadedApk.createAppFactory(LoadedApk.java:262)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:975)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:1062)
at android.app.LoadedApk.getResources(LoadedApk.java:1310)
at android.app.ContextImpl.createAppContext(ContextImpl.java:3037)
at android.app.ContextImpl.createAppContext(ContextImpl.java:3029)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6660)
at android.app.ActivityThread.access$1500(ActivityThread.java:256)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7870)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
FATAL EXCEPTION: main
Process: com.quare.blitzsplit, PID: 19725
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/Preconditions;
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
at android.app.ActivityThread.installProvider(ActivityThread.java:7459)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6976)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6747)
at android.app.ActivityThread.access$1500(ActivityThread.java:256)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7870)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.ClassNotFoundException:  com.google.android.gms.common.internal.Preconditions
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2) 
at android.app.ActivityThread.installProvider(ActivityThread.java:7459) 
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6976) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6747) 
at android.app.ActivityThread.access$1500(ActivityThread.java:256) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loopOnce(Looper.java:201) 
at android.os.Looper.loop(Looper.java:288) 
at android.app.ActivityThread.main(ActivityThread.java:7870) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 
Вот мой файл libs.versions.toml:

Код: Выделить всё

[versions]
datastore = "1.1.2"
hilt = "2.51.1"
materialNavigation = "1.7.6"
retrofit = "2.9.0"
compose-bom = "2025.01.00"
activity-compose = "1.10.0"
firebase-bom = "33.8.0"
android-gradle-plugin = "8.8.0"
kotlin = "2.1.0"
google-services = "4.4.2"
credentials-play-service-auth = "1.5.0-rc01"
goolge-id = "1.1.1"
navigation-compose = "2.8.5"
hilt-navigation-compose = "1.2.0"
constraintLayoutCompose = "1.1.0"
coil = "2.6.0"
kotlinSerializationJson = "1.6.3"
gson = "2.10.1"
okHttp = "4.12.0"
firebase-crashlytics = "3.0.2"
kotlinxCoroutinesCore = "1.8.0"
permissions = "0.34.0"
inAppUpdateVersion = "2.1.0"
assertK = "0.26.1"
junit5 = "5.10.2"
mockk = "1.13.10"
junit5Plugin = "1.9.3.0"

[libraries]
androidXCredentials = { module = "androidx.credentials:credentials", version.ref = "credentials-play-service-auth" }
androidXCredentialsPlayServicesAuth = {module = "androidx.credentials:credentials-play-services-auth", version.ref = "credentials-play-service-auth" }
googleId = { module = "com.google.android.libraries.identity.googleid:googleid", version.ref = "goolge-id" }

# Compose
composeBom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
material-navigation = { module = "androidx.compose.material:material-navigation", version.ref = "materialNavigation" }
ui = { group = "androidx.compose.ui", name = "ui" }
uiGraphics = { group = "androidx.compose.ui", name = "ui-graphics" }
uiTooling = { group = "androidx.compose.ui", name = "ui-tooling" }
uiToolingPreview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
uiTestManifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
material3 = { group = "androidx.compose.material3", name = "material3" }
icons = { group = "androidx.compose.material", name = "material-icons-extended" }
activityCompose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
navigationCompose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation-compose" }
constraintLayoutCompose = { group = "androidx.constraintlayout", name = "constraintlayout-compose", version.ref = "constraintLayoutCompose" }

#Gson
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }

# Coil
coil = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }

# Lifecycle
viewModelKtx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx" }
lifecycleRuntimeCompose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose" }

# Hilt
daggerHilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
daggerHiltCompiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt"  }
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
hilt-core = { module = "com.google.dagger:hilt-core", version.ref = "hilt" }
hiltNavigationCompose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "hilt-navigation-compose" }

# Firebase
firebaseBom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebase-bom" }
firebaseAnalytics = { group = "com.google.firebase", name = "firebase-analytics" }
firebaseCrashlytics = { group = "com.google.firebase", name = "firebase-crashlytics" }
firebase-auth-ktx = { group = "com.google.firebase", name = "firebase-auth-ktx" }

# Retrofit
retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
retrofitConverterGson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit" }
okHttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okHttp" }

# Accompanist
accompanistPermissions = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "permissions" }

# In-App Update
inAppUpdate = { group = "com.google.android.play", name = "app-update", version.ref = "inAppUpdateVersion" }
inAppUpdateKtx = { group = "com.google.android.play", name = "app-update-ktx", version.ref = "inAppUpdateVersion" }

# Other
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesCore" }
datastorePreferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore" }
kotlinSerialization = { group = "org.jetbrains.kotlin", name = "kotlin-serialization", version.ref = "kotlin" }
kotlinSerializationJson = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinSerializationJson" }
googleServices = { group = "com.google.gms", name = "google-services", version.ref = "google-services" }

# Testing
assertK = { group = "com.willowtreeapps.assertk", name = "assertk", version.ref = "assertK" }
junit5Api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit5" }
mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
junit5Engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit5" }

[plugins]
androidLibrary = { id = "com.android.library", version.ref = "android-gradle-plugin" }
androidApplication = { id = "com.android.application", version.ref = "android-gradle-plugin" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
hiltAndroid = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
googleServices = { id = "com.google.gms.google-services", version.ref = "google-services" }
firebaseCrashLytics = { id = "com.google.firebase.crashlytics", version.ref = "firebase-crashlytics" }
junit5 = { id = "de.mannodermaus.android-junit5", version.ref = "junit5Plugin" }
В моем проекте много модулей, поэтому я помещу сюда только модуль :app. П р и н е о б х о д и м о с т и я д о п о л н ю д о п о л н и т е л ь н ы м и м о д у л я м и g r a d l e : < / p > < b r / > < c o d e > p l u g i n s { < b r / > a l i a s ( l i b s . p l u g i n s . a n d r o i d A p p l i c a t i o n ) < b r / > a l i a s ( l i b s . p l u g i n s . k o t l i n A n d r o i d ) < b r / > a l i a s ( l i b s . p l u g i n s . g o o g l e S e r v i c e s ) < b r / > a l i a s ( l i b s . p l u g i n s.hiltAndroid)
alias(libs.plugins.composeCompiler)
alias(libs.plugins.firebaseCrashLytics)
kotlin("kapt")
}

android {
namespace = "com.quare.blitzsplit"
compileSdk = project.property("compileSdkVersion").toString().toInt()

defaultConfig {
applicationId = "com.quare.blitzsplit"
minSdk = project.property("minSdkVersion").toString().toInt()
targetSdk = project.property("targetSdkVersion").toString().toInt()
versionCode = project.property("versionCode").toString().toInt()
versionName = project.property("versionName").toString()
ndk {
debugSymbolLevel = "FULL"
}
vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("debug")
}
}
kotlinOptions {
jvmTarget = project.property("jvmTarget").toString()
}
buildFeatures {
compose = true
buildConfig = true
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}

dependencies {
implementFeature(
Module.Feature.Home.Data,
Module.Feature.Home.Domain,
Module.Feature.Home.Presentation,
Module.Feature.Contacts.Data,
Module.Feature.Contacts.Domain,
Module.Feature.AddContactToGroup,
Module.Feature.Group.Data,
Module.Feature.Group.Domain,
Module.Feature.Group.Presentation,
Module.Feature.Groups.Data,
Module.Feature.Groups.Domain,
Module.Feature.Groups.Presentation,
Module.Feature.Debts.Data,
Module.Feature.Debts.ByUser.Data,
Module.Feature.Debts.ByUser.Domain,
Module.Feature.Debts.ByUser.Presentation,
Module.Feature.Debts.ByGroup.Data,
Module.Feature.Debts.ByGroup.Domain,
Module.Feature.Debts.ByGroup.Presentation,
Module.Feature.Main.Data,
Module.Feature.Main.Domain,
Module.Feature.Main.Presentation,
Module.Feature.Expense.Data,
Module.Feature.Expense.Domain,
Module.Feature.Expense.Presentation,
Module.Feature.CreateGroup.Data,
Module.Feature.CreateGroup.Domain,
Module.Feature.CreateGroup.Presentation,
Module.Feature.JoinGroup.Data,
Module.Feature.JoinGroup.Domain,
Module.Feature.JoinGroup.Presentation,
Module.Feature.Split,
Module.Feature.SplitDialog,
)
implementCore(
Module.Core.Activity,
Module.Core.Analytics,
Module.Core.User,
Module.Core.Navigation,
Module.Core.Provider.City,
Module.Core.Provider.Language,
Module.Core.Provider.Image,
)
implementUi(
Module.Ui.Theme,
Module.Ui.Component.Category,
Module.Ui.Utils,
)

// Compose
implementation(platform(libs.composeBom))
implementation(libs.ui)
implementation(libs.uiGraphics)
implementation(libs.uiToolingPreview)
implementation(libs.material3)
implementation(libs.navigationCompose)
debugImplementation(libs.uiTooling)
debugImplementation(libs.uiTestManifest)

// Hilt
implementation(libs.daggerHilt)
kapt(libs.daggerHiltCompiler)

// Retrofit
implementation(libs.retrofit)
implementation(libs.retrofitConverterGson)

// Firebase
implementation(platform(libs.firebaseBom))
implementation(libs.firebaseCrashlytics)

// In App Update
implementation(libs.inAppUpdate)
implementation(libs.inAppUpdateKtx)
}

// Allow references to generated code
kapt {
correctErrorTypes = true
}

hilt {
enableAggregatingTask = true
}

Вот мой файл proguard-rules.pro:

Код: Выделить всё

# Retrofit 2.x
-dontwarn retrofit2.**
-keep class retrofit2.** { *;  }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*
-keepclasseswithmembers class * {
@retrofit2.http.* ;
}

# Gson
-keep class com.google.gson.stream.** { *; }

# Keep fields with @SerializedName annotation
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName ;
}

# Preserve annotations and class members
-keep class * {
@com.google.gson.annotations.SerializedName ;
}

# Preserve CredentialManager and its dependencies
-if class androidx.credentials.CredentialManager
-keep class androidx.credentials.playservices.** {
*;
}
Я решил эту проблему, изменив это в своем Gradle для релизной версии:

Код: Выделить всё

            isMinifyEnabled = false
Но мне бы не хотелось отключать этот флаг. Как я могу решить проблему, не отключая ее?

Подробнее здесь: https://stackoverflow.com/questions/793 ... d-12-or-be
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»