dji-sdk / Mobile-SDK-Android-V5

MSDK V5 Sample
Other
247 stars 126 forks source link

Enabling virtual stick throws java.lang.NoClassDefFoundError #345

Closed IakovlevAA closed 4 weeks ago

IakovlevAA commented 1 month ago

Hi, when I'm trying to enable virtual stick on mini 3 pro(sdk version: 5.9.0) this error appears.

java.lang.NoClassDefFoundError: Failed resolution of: Ldji/v5/common/callback/CommonCallbacks$CompletionCallback;
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
at android.app.Instrumentation.newApplication(Instrumentation.java:1153)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1218)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6608)
at android.app.ActivityThread.access$1700(ActivityThread.java:232)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1966)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.ClassNotFoundException: Didn't find class "dji.v5.common.callback.CommonCallbacks$CompletionCallback" on path: DexPathList[[zip file "/data/app/com.example.scarab-jc__11Q-4jCWCLjgJwakCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.scarab-jc__11Q-4jCWCLjgJwakCQ==/lib/arm64, /data/app/com.example.scarab-jc__11Q-4jCWCLjgJwakCQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]

The code I am trying to run:

open class SDKApplication : Application() {

    private val msdkManagerVM: MSDKManagerVM by globalViewModels()
    private val vstickVM: VirtualStickVM by globalViewModels()

    override fun onCreate() {
        super.onCreate()

        // Ensure initialization is called first
        msdkManagerVM.initMobileSDK(this)
        vstickVM.enableVirtualStick(object : CommonCallbacks.CompletionCallback {
            override fun onSuccess() {
                ToastUtils.showToast("enableVirtualStick success.")
            }

            override fun onFailure(error: IDJIError) {
                ToastUtils.showToast("enableVirtualStick error,$error")
            }
        })
    }
}

The same thing appears in sample app, however If I am using testing tools everything seems fine. What could be the problem?
Could you provide the right method to enable virtual stick in application(not activity)?

dji-dev commented 1 month ago

Agent comment from yating.liao in Zendesk ticket #108505:

It is necessary to call com.secneo.sdk.Helper.install(). The other interfaces of the SDK can only be used after com.secneo.sdk.Helper.install() is completed. You can place your code in the activity if you are using com.secneo.sdk.Helper.install().

°°°