Mobile-SDK-Android icon indicating copy to clipboard operation
Mobile-SDK-Android copied to clipboard

ClassNotFoundException: Didn't find class "dji.log.DJILog"

Open vancuong0429 opened this issue 3 years ago • 5 comments

I have created custom UXKeys, When I run with proguard, It crashes when calling UXKeys.addNewKeyClass(CustomKeys::class.java) My code in application:

override fun onCreate() {
        super.onCreate()
        GlobalPreferencesManager.initialize(AppGlobalPreferences(this))
        UXKeys.addNewKeyClass(CustomKeys::class.java)
  }

I set up multiDexEnabled My version:

implementation ('com.dji:dji-sdk:4.16.1')
compileOnly ('com.dji:dji-sdk-provided:4.16.1')
implementation 'com.github.dji-sdk:Mobile-UXSDK-Beta-Android:v0.5.1'

My log error: Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Ldji/log/DJILog; at dji.ux.beta.core.communication.UXKeys.initializeKeyValueTypes(UXKeys.java:67) at dji.ux.beta.core.communication.UXKeys.addNewKeyClass(UXKeys.java:79) at com.abc.djidrone.MyApplication.onCreate(MyApplication.kt:88) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6097) at android.app.ActivityThread.-wrap1(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1791) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:7000) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

vancuong0429 avatar Sep 14 '22 10:09 vancuong0429

It must be something wrong with the minified. What happens if you disable the minified option in build.gradle file? Try the proguard-rules.pro files in our sample.

DJI-William avatar Sep 15 '22 03:09 DJI-William

If I disable minifyEnabled, it still works, Only problem with minifyEnabled = true, but not always. I logged this issue on firebase log, it's not much but quite a few of my users. My config release:

buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
}

I follow proguard-rules.pro link sample

vancuong0429 avatar Sep 15 '22 03:09 vancuong0429

Don't shirnkResources, it will cause some crashes.

DJI-William avatar Sep 15 '22 03:09 DJI-William

so, I only need to set shrinkResources = false? I will try and check the report on firebase Thanks @DJI-William

vancuong0429 avatar Sep 15 '22 03:09 vancuong0429

Hi @DJI-William D I updated the config:

buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
            minifyEnabled false
            shrinkResources false
            //applicationIdSuffix '.debug'
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

but sometimes until the crash. Log crash on firebase: Caused by java.lang.ClassNotFoundException: Didn't find class "dji.log.DJILog" on path: DexPathList[[zip file "/system/framework/com.android.future.usb.accessory.jar", zip file "/data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/base.apk", zip file "/data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/split_config.armeabi_v7a.apk", zip file "/data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/split_config.pt.apk", zip file "/data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/lib/arm, /data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/base.apk!/lib/armeabi-v7a, /data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/split_config.armeabi_v7a.apk!/lib/armeabi-v7a, /data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/split_config.pt.apk!/lib/armeabi-v7a, /data/app/com.acb.djidrone-86KN3YVpxlAtHeoFSCQrQg==/split_config.xxhdpi.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]

vancuong0429 avatar Oct 06 '22 03:10 vancuong0429