dji-sdk / Mobile-SDK-Android

DJI Mobile SDK for Android: http://developer.dji.com/mobile-sdk/
Other
994 stars 581 forks source link

ProGuard problem #343

Open SweetAn opened 6 years ago

SweetAn commented 6 years ago

DJI SDK 4.5.1

The debug app can run normally, but after confusing, the error is reported, and the confusing file of github is used.

Can you give me some advice?

Toast error is

The key does not match the format:component/index/key with index being a number or *.

Console error

08-21 16:30:44.253 7111-7181/? E/CrashReport: sys default last handle start!
08-21 16:30:44.253 7111-7181/? E/AndroidRuntime: FATAL EXCEPTION: dji_background_thread
                                                 Process: com.xxxxxx.fly, PID: 7111
                                                 java.lang.NullPointerException: Attempt to read from field 'java.lang.Number dji.midware.data.params.P3.ParamInfo.value' on a null object reference
                                                     at dji.internal.logics.FPVTipLogic.updateParamStatus(Unknown Source)
                                                     at dji.internal.logics.FPVTipLogic.access$700(Unknown Source)
                                                     at dji.internal.logics.FPVTipLogic$TipHandler.handleMessage(Unknown Source)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:150)
                                                     at android.os.HandlerThread.run(HandlerThread.java:61)
Michael-DJI commented 6 years ago

@SweetAn please use the latest version : 4.8. btw you could report the issue in Stackoverflow using "dji-sdk" tag, it will attract more attention of our supporting team.

tuanbipa commented 5 years ago

@Michael-DJI I am using 4.8.1 but this error still occurs, I sent an email to support

Michael-DJI commented 5 years ago

@tubipham ok, pls don't forget describe the steps, how to reproduce the issue.

coptercam commented 5 years ago

Same problem, running SDK 4.9 on android. No issues with debug build, but with release build the app crashes and I get the error message in the logs

java.lang.NullPointerException: Attempt to read from field 'java.lang.Number dji.midware.data.params.P3.ParamInfo.value' on a null object reference

tuanbipa commented 5 years ago

After I change the release configuration, I don't get this error again. This is my configuration, try it:

    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

But if I change it like below then I will get a "java.lang.NullPointerException" error:

    release {
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

@Michael-DJI plz check

coptercam commented 5 years ago

I can confirm that removing the shrinkResources, minifyEnabled and proguardfiles from the release build resolved the problem. But that isn't ideal because I want to enable proguard and reduce my apk size.

tuanbipa commented 5 years ago

@coptercam I also want that like you, it looks like we need an updated version from DJI @Michael-DJI fyi

coptercam commented 5 years ago

Nice to see the DJI still hasn't fixed this problem yet 6 months later

Michael-DJI commented 5 years ago

@coptercam sorry for the inconvenience! I will push the developer to look into it, thanks for the feedback!

Hoker- commented 5 years ago

@coptercam I try it on sample,and bulid release with shrinkResources, minifyEnabled true。 phone:honor magic 2 android 9 aircraft: mavic pro sdk version:4.9 and use LogicManager.getInstance().startFPVTipLogic(); I can not reproduce the crash. can you tell me the condition you found the crash?

coptercam commented 5 years ago

@coptercam I try it on sample,and bulid release with shrinkResources, minifyEnabled true。 phone:honor magic 2 android 9 aircraft: mavic pro sdk version:4.9 and use LogicManager.getInstance().startFPVTipLogic(); I can not reproduce the crash. can you tell me the condition you found the crash?

This is the error log (resolved after disabling proguard as recommended by @tubipham

2019-02-23 22:32:29.948 1274-1306/? E/AndroidRuntime: FATAL EXCEPTION: dji_background_thread Process: com.aeroranger.beta.air, PID: 1274 java.lang.NullPointerException: Attempt to read from field 'java.lang.Number dji.midware.data.params.P3.ParamInfo.value' on a null object reference at dji.internal.logics.FPVTipLogic.updateParamStatus(Unknown Source:21) at dji.internal.logics.FPVTipLogic.access$700(Unknown Source:0) at dji.internal.logics.FPVTipLogic$TipHandler.handleMessage(Unknown Source:64) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:166) at android.os.HandlerThread.run(HandlerThread.java:65)

Michael-DJI commented 5 years ago

@coptercam the crash in not in our sample right? did you add some UXSDK widgets in your layout?

Hoker- commented 5 years ago

@coptercam what is you aircraft and phone verison?

tuanbipa commented 5 years ago

I used SDK 4.9 and some UXSDK widgets. Device: Phantom3 pro. Android: Sky A900 OS: 7.1

@Hoker- Have you tried attaching shrinkResources like I described in your configuration file? @Michael-DJI fyi

kenargo commented 5 years ago

What is the contents of your proguard file?

You can't just enable minify and expect things to work,  you must add the correct proguard rules so that minify doesn't disguard need code

⁣Sent from BlueMail ​

On Mar 27, 2019, 8:29 PM, at 8:29 PM, Hai notifications@github.com wrote:

@coptercam I try it on sample,and bulid release with shrinkResources, minifyEnabled true。 phone:honor magic 2 android 9 aircraft: mavic pro sdk version:4.9 and use LogicManager.getInstance().startFPVTipLogic(); I can not reproduce the crash. can you tell me the condition you found the crash?

This is the error log (resolved after disabling proguard as recommended by @tubipham

2019-02-23 22:32:29.948 1274-1306/? E/AndroidRuntime: FATAL EXCEPTION: dji_background_thread Process: com.aeroranger.beta.air, PID: 1274 java.lang.NullPointerException: Attempt to read from field 'java.lang.Number dji.midware.data.params.P3.ParamInfo.value' on a null object reference at dji.internal.logics.FPVTipLogic.updateParamStatus(Unknown Source:21) at dji.internal.logics.FPVTipLogic.access$700(Unknown Source:0) at dji.internal.logics.FPVTipLogic$TipHandler.handleMessage(Unknown Source:64) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:166) at android.os.HandlerThread.run(HandlerThread.java:65)

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/dji-sdk/Mobile-SDK-Android/issues/343#issuecomment-477129643

tuanbipa commented 5 years ago

I and @coptercam wanted to activate "shrinkResources = true" to reduce the size of the .apk file, but when I added it, we all received a crash from the DJI SDK. Below is my configuration section, it works well with the release. release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' }

coptercam commented 5 years ago

@coptercam the crash in not in our sample right? did you add some UXSDK widgets in your layout?

Correct

coptercam commented 5 years ago

@coptercam what is you aircraft and phone verison?

Mavic Pro and others HTC Mate 8 Android 8 Crystal Sky Android 5.1

Didn't have any proguard issues until SDK 4.81 and 4.9

Michael-DJI commented 5 years ago

did you ever check this proguard file out? https://github.com/dji-sdk/Mobile-SDK-Android/blob/master/proguard-project.txt

mtruese commented 5 years ago

Just to chime in here. I am also using UXSDK version 4.9 and have experienced issues with proguard. Have used the above proguard file but it does not fix the issue. Receiving the same error as well. "Java.lang.Number dji.midware.data.params.P3.ParamInfo.value' on a null object reference at ". Error only occurs when using shrink and minify.

Michael-DJI commented 5 years ago

@mtruese really appreciate your feedback, it might related with the UXSDK, we will continue to investigate it! thanks!

Michael-DJI commented 5 years ago

pls check this out : https://github.com/dji-sdk/Mobile-SDK-Android/issues/239

mtruese commented 5 years ago

Added the keep.xml file but no change in behavior.

Michael-DJI commented 5 years ago

Added the keep.xml file but no change in behavior.

how about the crash stack? no change too?

mtruese commented 5 years ago

This is from the latest crash. The crash occurs when the drone is connected to the application. No crash if not connected. Caused by: dji.thirdparty.rx.exceptions.OnErrorNotImplementedException: Attempt to read from field 'java.lang.Number dji.midware.data.params.P3.ParamInfo.value' on a null object reference at

Edit: Looks like it did actually solve the issue. After putting the keep.xml file back in place I rebuilt using an additional 2 lines in the proguard and so far seems to be working properly. -dontwarn com.google.auto.value. -dontwarn com.sun.xml.internal.ws.spi.db.

smaorus commented 5 years ago

Still facing this issue with the exact same crash stack, even after adding the keep.xml file and making sure all proguard statements exist in our proguard file. Perhaps i've put the keep file in the wrong location?