Рукоять кинжала: java.lang.RuntimeException: невозможно создать экземпляр приложения java.lang.ClassNotFoundException: нAndroid

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Рукоять кинжала: java.lang.RuntimeException: невозможно создать экземпляр приложения java.lang.ClassNotFoundException: н

Сообщение Anonymous »

Я пробую рукоять кинжала и пытаюсь устранить эту ошибку в течение последних двух дней, но ничего не помогает
Я все еще застрял. Я использую новую версию gradle (version=8.6), которая меня немного смущает.
ошибка
java.lang.RuntimeException: Unable to instantiate application com.example.test2dagcln.CoinApplication: java.lang.ClassNotFoundException: Didn't find class "com.example.test2dagcln.CoinApplication" on path: DexPathList[[zip file "/data/app/com.example.test2dagcln-GhkXDfUqFpRj-HO3VSzjOA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.test2dagcln-GhkXDfUqFpRj-HO3VSzjOA==/lib/arm, /system/lib, /product/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1232)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6574)
at android.app.ActivityThread.access$1500(ActivityThread.java:235)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:225)
at android.app.ActivityThread.main(ActivityThread.java:7563)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.test2dagcln.CoinApplication" on path: DexPathList[[zip file "/data/app/com.example.test2dagcln-GhkXDfUqFpRj-HO3VSzjOA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.test2dagcln-GhkXDfUqFpRj-HO3VSzjOA==/lib/arm, /system/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:51)
at android.app.Instrumentation.newApplication(Instrumentation.java:1155)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1224)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6574) 
at android.app.ActivityThread.access$1500(ActivityThread.java:235) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:225) 
at android.app.ActivityThread.main(ActivityThread.java:7563) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994) 
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/test2dagcln/Hilt_CoinApplication;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 14 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.test2dagcln.Hilt_CoinApplication" on path: DexPathList[[zip file "/data/app/com.example.test2dagcln-GhkXDfUqFpRj-HO3VSzjOA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.test2dagcln-GhkXDfUqFpRj-HO3VSzjOA==/lib/arm, /system/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 17 more

build.gradle.kts(app)
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.hilt)
}

android {
namespace = "com.example.test2dagcln"
compileSdk = 34

defaultConfig {
applicationId = "com.example.test2dagcln"
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)

// Compose dependencies
implementation (libs.androidx.lifecycle.viewmodel.compose)
implementation (libs.androidx.navigation.compose)
implementation (libs.accompanist.flowlayout)

// Coroutines
implementation (libs.kotlinx.coroutines.core)
implementation (libs.kotlinx.coroutines.android)

// Coroutine Lifecycle Scopes
implementation (libs.androidx.lifecycle.viewmodel.ktx)
implementation (libs.androidx.lifecycle.runtime.ktx)

//Dagger - Hilt
implementation (libs.hilt.android)
annotationProcessor (libs.hilt.android.compiler)
implementation (libs.androidx.hilt.lifecycle.viewmodel)
annotationProcessor (libs.androidx.hilt.compiler)
implementation (libs.androidx.hilt.navigation.compose)

// Retrofit
implementation (libs.retrofit)
implementation (libs.converter.gson)
implementation (libs.okhttp)
implementation (libs.logging.interceptor)
}

libs.version.toml
[versions]
accompanistFlowlayout = "0.17.0"
agp = "8.4.0"
converterGson = "2.9.0"
hiltAndroid = "2.49"
hiltAndroidCompiler = "2.49"
hiltCompiler = "1.2.0"
hiltLifecycleViewmodel = "1.0.0-alpha03"
kotlin = "1.9.0"
coreKtx = "1.13.1"
junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
kotlinxCoroutinesCore = "1.7.3"
kotlinxCoroutinesAndroid = "1.7.3"
lifecycleRuntimeKtx = "2.8.0"
activityCompose = "1.9.0"
composeBom = "2023.08.00"
hilt="2.49"
loggingInterceptor = "5.0.0-alpha.2"
navigationCompose = "2.7.7"
okhttp = "5.0.0-alpha.2"

[libraries]
accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayout", version.ref = "accompanistFlowlayout" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-hilt-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hiltCompiler" }
androidx-hilt-lifecycle-viewmodel = { module = "androidx.hilt:hilt-lifecycle-viewmodel", version.ref = "hiltLifecycleViewmodel" }
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hiltCompiler" }
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleRuntimeKtx" }
converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "converterGson" }
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hiltAndroidCompiler" }
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinxCoroutinesAndroid" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesCore" }
logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "loggingInterceptor" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "converterGson" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }


build.gradle(проект)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.hilt) apply false
}

settings.gradle.kts
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

rootProject.name = "Test2DagCln"
include(":app")


AndroidManifest.xml

















CoinApplication
@HiltAndroidApp
class CoinApplication : Application() {
override fun onCreate() {
super.onCreate()
Log.d("Test", "CoinApplication found!")
}
}


Подробнее здесь: https://stackoverflow.com/questions/785 ... ation-java
Реклама
Ответить Пред. темаСлед. тема

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

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

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

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

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

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