dji-sdk / Mobile-SDK-Android

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

Connection Issue (Android 7.0) #232

Open MikeWoots opened 6 years ago

MikeWoots commented 6 years ago

I am having an issue with connecting to the drone which only seems effect devices running Android 7.

Description: The first time I compile and install the app on my device I can connect to the drone perfectly. However, if I then either turn off the remote or unplug the USB cable and try then reconnect again the connection fails. onProductChange in DJISDKManager.SDKManagerCallback is not called.

How to replicate: 1) Turn on drone and keep powered on for entire test 2) Turn on remote and connect to DJI SDK 3) Turn off remote 4) Turn on remote back on and try reconnect 5) Connection then fails, in particular onProductChange is not called

Phantom 4 Android 7.0

zzhall commented 6 years ago

Got same issue like you today. Are you still using SDK v4.3.2 like me?

MikeWoots commented 6 years ago

I experienced this issue on v4.4.1

zzhall commented 6 years ago

I have spent several hour to work around it, but still have no idea. It is strange that connection is all good on another demo, which has almost the same structure with the current one.

MikeWoots commented 6 years ago

It is difficult to debug because you have to have your device connected to the remote via USB and using DJI bridge won't work to debug either. I think disconnecting the remote must be breaking the SDK but haven't been able to find a way to record the logs yet.

zzhall commented 6 years ago

Well, I work around the debug problem via wifi adb. There is a AS plugin named WIFI ADB ULTIMATE. You can connect to mobile device via IP address and port number after plugging the USB cable into remote controller. And then all logs are avaliable in the Logcat.

MikeWoots commented 6 years ago

Thanks, I had forgotten about wifi adb. Will test it again today and see if I can pick up anything in the logs

MikeWoots commented 6 years ago

Have you tried using wifi adb? Whenever I connect to the drone remote via usb I get disconnected from the wifi adb connection.

zzhall commented 6 years ago

Yes, that's the way it is. Connecting to remote controller will Interrupt the wifi adb connection if adb is already connected. And you need to reconnect to wifi adb, then you can get both drone and mobile device status the same time.

markdjacobsen commented 6 years ago

FWIW, I am encountering the same problem, running Android 7.0 with both v4.3.2 and v4.4.1

cwbsl commented 6 years ago

Same here, running Android 8.1.0 and DJI SDK 4.4.1, using the exact startSDKRegistration() method from the sample, app registration works great but then startConnectionToProduct() returns false AND onProductChange() is not called when connecting to the drone...

MikeWoots commented 6 years ago

I still haven't found a solution to this. Would be great to get some feedback from DJI.

markdjacobsen commented 6 years ago

Still broken with SDK 4.5.

talobin commented 6 years ago

@jacobsenmd We are able to reproduce this on our side now. Will fix this soon and keep this thread posted.

codeversed commented 6 years ago

Any progress on this issue? It wastes lots of time and seems to be random.

wenhaopeter commented 6 years ago

I also have this problem. Is there a solution

samuelo91 commented 5 years ago

Hey everyone, I had the same problem. It turned out that somehow the onRegister method returned a DJISDKError.REGISTRATION_SUCCESS although registering failed (the problem was that my phone wasn't connected to the internet). So if you make sure you have an internet connection when doing the first register call the product connects.

At least this worked for me.

sapir1779 commented 5 years ago

The same happens to me with Crystal Sky, DJI SDK 4.8.1. Has anyone got any clue as to why this is happening and how we can fix it?

yakovchang commented 5 years ago

Still broken with SDK 4.8. Any solution?

zzhall commented 5 years ago

Well, I worked around it a year ago. Simply by removing the dependency of JPush SDK, a third-party message push platform. But I don't think it's a universal solution for all developers who are facing this problem. DJI SDK registration process seems to be blocked by some third-party develop kit. Maybe you could try to work around it on this aspect.

vorobotics commented 4 years ago

I described my workaround for this issue in issue #479

Essentially setting your main activity android:launchMode = "singleTop" ensures that the existing instance of the activity will receive the USB connection Intent, which you can pass along to the SDK to ensure that the SDK reinitializes correctly on USB unplug / replug.

fernando-s97 commented 3 years ago

2 years later and the error still exists in version 4.13.1 with Android 9. Any updates?

fernando-s97 commented 3 years ago

@talobin SDK 4.15, and more than 3 years later this issue is still open. Any reason why there is no progress on this even though you were able to reproduce this on your side?

When will this "soon" arrive?

OBS: also got this issue on Android 11