Please select Into the mobile phone version | Continue to access the computer ver.
getPackageName exception on 4.13 msdk android
65 2 11-4 11:11
Uploading and Loding Picture ...(0/1)
o(^-^)o
randyranderson
lvl.1

United States
Offline

I recently updated my app to 4.13, code that I took from a previous sdk that worked is now crasing with a null pointer exception below. I doubled back and tried to take the example from https://github.com/dji-sdk/Mobile-SDK-Android.git and the same result any time I call into any of the following the app crashes:


UserAccountManager.getInstance().getUserAccountState();
UserAccountManager.getInstance().logIntoDJIUserAccount();
UserAccountManager.getInstance().logoutOfDJIUserAccount();

is there some new Init() i'm not calling or permissions I'm missing? LoginView.java is from the mobilesdk example above.


2020-11-04 13:59:06.125 11973-11973/com.mydomain.android.myapp.dji E/ACRA: ACRA caught a NullPointerException for com.mydomain.android.myapp.dji
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
        at dji.midware.util.jhg.fdd(Unknown Source:0)
        at dji.midware.util.jhg.fdd(Unknown Source:0)
        at dji.internal.useraccount.nbb.ghu(Unknown Source:12)
        at dji.internal.useraccount.nbb.nhf(Unknown Source:4)
        at dji.sdk.useraccount.UserAccountManager.updateInternalUserAccountState(Unknown Source:8)
        at dji.sdk.useraccount.UserAccountManager.<init>(Unknown Source:3)
        at dji.sdk.useraccount.UserAccountManager.getInstance(Unknown Source:9)
        at com.mydomain.android.myapp.activity.LoginView.onClick(LoginView.java:49)
        at android.view.View.performClick(View.java:6877)
        at android.widget.TextView.performClick(TextView.java:12651)
        at android.view.View$PerformClick.run(View.java:26072)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6938)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)


11-4 11:11
Use props
DJI-William
lvl.4

South Africa
Offline

Stange, I havn't seen this error before.The MSDK sample project has been updated to 4.13.1. I have download it and tried it the project doesn't crashed. Maybe try update your SDK version to 4.13.1 and try again.
11-5 01:33
Use props
randyranderson
lvl.1

United States
Offline

DJI-William Posted at 11-5 01:33
Stange, I havn't seen this error before.The MSDK sample project has been updated to 4.13.1. I have download it and tried it the project doesn't crashed. Maybe try update your SDK version to 4.13.1 and try again.

Fixed, build.gradle needed the following added:
    implementation "androidx.core:core-ktx:+"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0-rc01"

11-5 06:53
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules