After updating some libraries my huawei app is crashing when launching. The splash screen is shown for 1 second and then the app stops.
I updated agconnect to the latest version (1.9.1.303) and my gradle version is 8.6.0.
And these are the logs:
java.lang.NoClassDefFoundError: Failed resolution of: Lro/datakit/util/EventBus;
at ro.base.architecture.activity.BaseActivity.Y2(SourceFile:8)
at ro.base.architecture.activity.BaseActivity.A2(SourceFile:27)
at ro.base.architecture.activity.BaseActivity.onCreate(SourceFile:4)
at ro.ui.auth.login.activity.LoginActivity.onCreate(SourceFile:1)
at android.app.Activity.performCreate(Activity.java:8086)
at android.app.Activity.performCreate(Activity.java:8074)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1313)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3755)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3961)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2386)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:8178)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
Caused by: java.lang.ClassNotFoundException: ro.datakit.util.EventBus
... 19 more
Here are my libraries:
googleImplementation 'com.huawei.hms:location:6.7.0.300'
googleImplementation 'com.huawei.hms:maps:6.6.1.301'
// huawei libs
huaweiImplementation 'com.huawei.agconnect:agconnect-core:1.9.1.303'
huaweiImplementation 'com.huawei.hms:base:6.2.0.300'
huaweiImplementation 'com.huawei.hms:hwid:6.12.0.300'
huaweiImplementation 'com.huawei.hms:push:6.12.0.300'
huaweiImplementation 'com.huawei.hms:hianalytics:6.7.0.300'
huaweiImplementation 'com.huawei.agconnect:agconnect-crash:1.9.1.303'
huaweiImplementation 'com.huawei.hms:location:6.7.0.300'
huaweiImplementation 'com.huawei.hms:maps:6.11.0.304'
huaweiImplementation 'dev.supasintatiyanupanwong.libraries.android.huawei.maps:maps-utils:1.0.0-alpha03'
allprojects {
buildscript {
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:8.6.0'
classpath "io.realm:realm-gradle-plugin:10.18.0"
classpath 'com.google.gms:google-services:4.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Add the Firebase Crashlytics Gradle plugin.
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath 'com.huawei.agconnect:agcp:1.9.1.303'
classpath 'com.huawei.hms.plugin:analytics:5.0.1.300'
}
}
}
Here is my EventBus class which you can see it’s in the correct path.
package ro.datakit.util
import androidx.lifecycle.MutableLiveData
import ro.datakit.rest.response.auth.AuthorizeResponse
object EventBus {
val BUS = MutableLiveData<AuthorizeResponse>()
val LOGOUT_BUS = MutableLiveData<Boolean>()
}
Also here is my build.gradle (:datakit)
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
apply plugin: 'realm-android'
android {
compileSdk 34
publishNonDefault true
defaultConfig {
minSdkVersion 23
buildConfigField "boolean", "SHOW_CAN_NETWORK_CONSOLE", "false"
}
flavorDimensions "default", "services"
productFlavors {
live {
dimension "default"
}
stage {
dimension "default"
buildConfigField "boolean", "SHOW_CAN_NETWORK_CONSOLE", "true"
}
dev {
dimension "default"
}
preprod {
dimension "default"
buildConfigField "boolean", "SHOW_CAN_NETWORK_CONSOLE", "true"
}
google {
dimension "services"
}
huawei {
dimension "services"
}
}
buildTypes {
release {
minifyEnabled false
proguardFile 'proguard-project.pro'
proguardFile getDefaultProguardFile('proguard-android.txt')
}
debug {
}
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
lint {
abortOnError false
ignoreWarnings true
quiet true
}
namespace 'ro.datakit'
}
dependencies {
// kotlin
api 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.5'
api project(':basic')
}
realm {
syncEnabled = false
}
repositories {
mavenCentral()
}
5
After hours of research I discovered that adding android.enableR8.fullMode=false
to my gradle.properties
file solved the issue. No idea why, but maybe this will help someone.