miguelhincapie / CustomBottomSheetBehavior

Custom BottomSheetBehavior for Android that mimic Google Maps behavior
Apache License 2.0
915 stars 184 forks source link

NullPointerException at 288 line in BottomSheetBehaviorGoogleMapsLike #55

Closed frank-vi closed 6 years ago

frank-vi commented 6 years ago

hi, i just want to test your app without adding code, but i get this error:

FATAL EXCEPTION: main java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.widget.ViewDragHelper.processTouchEvent(android.view.MotionEvent)' on a null object reference at com.mahc.custombottomsheetbehavior.BottomSheetBehaviorGoogleMapsLike.onTouchEvent(BottomSheetBehaviorGoogleMapsLike.java:288) at android.support.design.widget.CoordinatorLayout.resetTouchBehaviors(CoordinatorLayout.java:389) at android.support.design.widget.CoordinatorLayout.onAttachedToWindow(CoordinatorLayout.java:235) at android.view.View.dispatchAttachedToWindow(View.java:15509) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2916) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1526) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:621) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

miguelhincapie commented 6 years ago

Hi, did you move any gradle config? (min SDK, libraries version,...) If not, can you give me more details about what you were doing and mobile specs (emulator or device)?

frank-vi commented 6 years ago

Hi, thanks for the replay. In the module-level build.gradle file i only add this library and Design Support Library. I have reported the complete file below.

`apply plugin: 'com.android.application'

android { compileSdkVersion 27 defaultConfig { applicationId "it.example.googlelike" minSdkVersion 18 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.0.2' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

implementation 'com.mahc.custombottomsheetbehavior:googlemaps-like:0.9.1'
implementation 'com.android.support:design:27.0.2'

}`

I use two emulators with these specifics:

Name: Nexus_4_API_25 CPU/ABI: Google APIs Intel Atom (x86) Target: google_apis [Google APIs] (API level 25) SD Card: 100M hw.lcd.height: 1280 hw.lcd.width: 768 hw.lcd.density: 320 vm.heapSize: 80 image.androidVersion.api: 25 image.sysdir.1: system-images\android-25\google_apis\x86\ showDeviceFrame: yes hw.ramSize: 1536 hw.cpu.ncore: 2 disk.dataPartition.size: 800M

and

Name: Pixel_API_18 CPU/ABI: Google APIs Intel Atom (x86) Target: google_apis [Google APIs] (API level 18) Skin: 1080x1920 SD Card: 100M hw.lcd.height: 1920 hw.lcd.width: 1080 hw.lcd.density: 480 vm.heapSize: 256 image.androidVersion.api: 18 hw.ramSize: 1536 hw.cpu.ncore: 2 disk.dataPartition.size: 800M

repitch commented 6 years ago

I assume it's cause 27.0.2 support library version. Now project works on 26.1.0 version.

repitch commented 6 years ago

I've just compared source code for original BottomSheetBehavior 26.1.0 - 27.0.2 and here what's changed: image So, just need to add check mViewDragHelper for null

repitch commented 6 years ago

After upgrading to 27.0.2 and applying this fix something happened with swipe: bottomsheet_after_27 0 2

I'm figuring out why does it happen. For some reason mScrollVelocityTracker.clear() is called between onNestedPreScroll and onStopNestedScroll. So scrollVelocity is missing

miguelhincapie commented 6 years ago

@repitch thank you for that, you are welcome to create a PR with that improve :)

repitch commented 6 years ago

@miguelhincapie Working on that!

repitch commented 6 years ago

57 - pull request is created

miguelhincapie commented 6 years ago

PR merged, Thank you for that! :D

usergoodvery commented 6 years ago

Hi, I have the same problem on 27.0.2. Checking the code though, where exception was thrown, the check for null suggested by @repitch doesn't seem to be in. Is this the most uptodate package: 'com.mahc.custombottomsheetbehavior:googlemaps-like:0.9.2'?

miguelhincapie commented 6 years ago

Hi there, nope, I merged the PR but I still dont push it to bintray. Give me this week and Im gonna do it.

usergoodvery commented 6 years ago

good on you thanks

usergoodvery commented 6 years ago

Hi Is this updated yet?

Tweener commented 6 years ago

Hi,

Just following up on this thread. It would be nice to have the new version, including this fix, uploaded to Bintray. Any idea of when is it supposed to be released?

This library is awesome. Thanks for sharing! Keep on the good work 👍

miguelhincapie commented 6 years ago

Hi there, sorry for the delay, I'm going to set up travis ci, github and bintray to avoid have to do it manually every time. Starting to look how to do it today at night.

Tweener commented 6 years ago

Alright, thanks a lot! Hopefully you won't struggle too much to set this all up :) Keep us posted! Cheers

miguelhincapie commented 6 years ago

New version 0.9.2 here.

I did it manually because linking bintray with travis CI and github is hard to achieve :S. I'm gonna keep trying, if someone wants to join me in the journery here is the link for brintray.gradle file if you wanna understand how it works.

usergoodvery commented 6 years ago

great thanks i'll give that a go

Tweener commented 6 years ago

Hi @miguelhincapie ! Thanks for the upload. About automatic upload to Bintray, I guess you meant "Travis CI", unfortunately, I've never worked with it. I don't know if this can help but better sharing than keeping it for myself: https://github.com/mbonaci/mbo-storm/wiki/Integrate-Travis-CI-with-your-GitHub-repo

Tweener commented 6 years ago

Also I tested the version 0.9.2, and I can confirm I don't have this NPE anymore. So problem fixed, congrats :)