box / box-android-preview-sdk

Box Android Preview SDK
Apache License 2.0
13 stars 10 forks source link

NullPointerException in BoxPreviewActivity after updating to version 2.1.0. #20

Closed yev-kanivets closed 5 years ago

yev-kanivets commented 5 years ago

Hello,

Box Support contacted our team with an issue of using TLS 1.0, which will be discontinued at November. To resolve the issue we updated the box-android-preview-sdk from version 2.0.4 to 2.1.0. Latest version includes the right version of box-android-sdk (4.2.0), which switched to TLS 1.1.

But after raising the version of box-android-preview-sdk up to 2.1.0, we are constantly getting the crash, when trying to open any media file through Box Preview SDK on Android.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.m360.android.debug, PID: 9175
    java.lang.NullPointerException: Attempt to invoke virtual method 'com.box.androidsdk.content.models.BoxIteratorItems com.box.androidsdk.content.models.BoxFolder.getItemCollection()' on a null object reference
        at com.box.androidsdk.preview.ui.BoxPreviewActivityImpl.loadContent(BoxPreviewActivityImpl.java:76)
        at com.box.androidsdk.preview.BoxPreviewActivity.b(BoxPreviewActivity.java:266)
        at com.box.androidsdk.preview.BoxPreviewActivity.handleBoxResponse(BoxPreviewActivity.java:335)
        at com.box.androidsdk.preview.ext.BoxThreadPoolExecutorActivity.a(BoxThreadPoolExecutorActivity.java:164)
        at com.box.androidsdk.preview.ext.BoxThreadPoolExecutorActivity.a(BoxThreadPoolExecutorActivity.java:34)
        at com.box.androidsdk.preview.ext.BoxThreadPoolExecutorActivity$1.onReceive(BoxThreadPoolExecutorActivity.java:59)
        at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:311)
        at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:47)
        at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:120)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Could you, please, help us to resolve the issue or at least understand what's going wrong?

yev-kanivets commented 5 years ago

@doncung didn't you had a time to take a look into issue? November 12th deadline is approaching very fast and I'm not sure that version 2.0.4 will work when Box deprecates TLS 1.0.

yev-kanivets commented 5 years ago

If anybody has the similar problem, here is a workaround:

implementation('com.box:box-android-preview-sdk:2.0.4') {
    exclude group: 'com.box', module: 'box-android-sdk'
  }
implementation 'com.box:box-android-sdk:4.2.0'

It just swaps box-android-sdk to the latest one, which enables TLS 1.1 support.

doncung commented 5 years ago

Thank you for posting your work around. We are currently working on an updated preview sdk that improves on our audio and video functionality which should hopefully also fix this issue.

Trying the 2.1.0 sdk in a sample app, I'm not seeing the same crash you are. So I'm not sure exactly why you are getting a null pointer at that line. The line is trying to get other items in the folder that the file is in, and comes from a network call that has pulled updated data. As such my guess is that it crashes if you are trying to access a shared link that you don't have a folder for?

yev-kanivets commented 5 years ago

@doncung yes, I'm getting just a file without folder using a token which is unique to only that file. This is done for security reasons, because other way the user with a token which gives an access to folder also can access all the files of other users. And yes, all files are located in one folder, which is not the best, but legacy solution.

yev-kanivets commented 5 years ago

@doncung btw, what will be the behavior of version 2.0.4, which doesn't support a TLS 1.1 after November 12th? Will it stop working?

doncung commented 5 years ago

For users below 21 than yes api calls will start throwing exceptions. The latest content sdk has some logic that can support down to 16. This is to help developers transition, but officially we support 21+ now.

On Thu, Nov 8, 2018, 12:23 AM Evgenii Kanivets <notifications@github.com wrote:

@doncung https://github.com/doncung btw, what will be the behavior of version 2.0.4, which doesn't support a TLS 1.1 after November 12th? Will it stop working?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/box/box-android-preview-sdk/issues/20#issuecomment-436911269, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmHYtgE8nROl3UycMSygpxpPuf8oxRuks5us-obgaJpZM4YCAfb .

yev-kanivets commented 5 years ago

@doncung I've got it, thanks. Probably, you should update a README to this repo then to recommend latest version of SDK

compile 'com.box:box-android-preview-sdk:2.0.4'

And also I'm not sure how other developers will know that they should update the version before November 12th. Our team were contacted by Box Support with an issue of using TLS 1.0, but it wasn't concrete about where we use it. And only after some investigations I've found that com.box:box-android-sdk:4.2.0 introduces TLS 1.1. So it was not very obvious change :/

yev-kanivets commented 5 years ago

Fixed with latest version.