Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample app crashes when Contact List Example clicked on Xperia X Performance #7

Closed
rayliverified opened this issue Apr 26, 2017 · 35 comments
Labels

Comments

@rayliverified
Copy link

rayliverified commented Apr 26, 2017

How to reproduce on Xperia X Performance:

  1. Install the latest repo code.
  2. Click "Contact List Example"
  3. App crashes with the error below.
04-25 23:35:30.861 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@a748111
04-25 23:35:30.926 10895-10895/com.pchmn.sample.materialchipsinput I/Timeline: Timeline: Activity_launch_request id:com.pchmn.sample.materialchipsinput time:29040260
04-25 23:35:31.000 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@fe9ec7c
04-25 23:35:31.001 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@8fa905
04-25 23:35:31.051 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@a944526
04-25 23:35:31.051 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@f973567
04-25 23:35:31.055 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@82ef3bd
04-25 23:35:31.055 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@b6f8db2
04-25 23:35:31.079 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@557c103
04-25 23:35:31.079 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@e7e4880
04-25 23:35:31.317 10895-10895/com.pchmn.sample.materialchipsinput I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@f78e4e4 time:29040651
04-25 23:35:31.506 10895-10956/com.pchmn.sample.materialchipsinput D/OpenGLRenderer: endAllActiveAnimators on 0x7f88aaf000 (RippleDrawable) with handle 0x7f88ab1400
04-25 23:35:34.783 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@bdbe4d3
04-25 23:35:34.784 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@a8ae810
04-25 23:35:34.806 10895-10895/com.pchmn.sample.materialchipsinput W/System.err: io.reactivex.exceptions.OnErrorNotImplementedException
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmitScalar(ObservableFlatMap.java:234)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:146)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableBuffer$BufferExactObserver.onNext(ObservableBuffer.java:113)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmit(ObservableFlatMap.java:262)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$InnerObserver.onNext(ObservableFlatMap.java:559)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:112)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableConcatMap$SourceObserver$InnerObserver.onNext(ObservableConcatMap.java:249)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:265)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:184)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:64)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:49)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.Activity.dispatchRequestPermissionsResultToFragment(Activity.java:7120)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.Activity.dispatchActivityResult(Activity.java:6966)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread.deliverResults(ActivityThread.java:4162)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread.handleSendResult(ActivityThread.java:4209)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread.-wrap20(ActivityThread.java)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.os.Looper.loop(Looper.java:241)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6223)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err: Caused by: java.lang.NullPointerException
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.text.RuleBasedCollator.compare(RuleBasedCollator.java:356)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.adapter.FilterableAdapter$1.compare(FilterableAdapter.java:66)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.adapter.FilterableAdapter$1.compare(FilterableAdapter.java:61)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.util.TimSort.countRunAndMakeAscending(TimSort.java:351)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.util.TimSort.sort(TimSort.java:230)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.util.Arrays.sort(Arrays.java:1523)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.util.Collections.sort(Collections.java:238)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.adapter.FilterableAdapter.<init>(FilterableAdapter.java:61)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.views.FilterableListView.build(FilterableListView.java:66)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.ChipsInput.setFilterableList(ChipsInput.java:342)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.sample.materialchipsinput.ContactListActivity.getContactList(ContactListActivity.java:124)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.sample.materialchipsinput.ContactListActivity.lambda$onCreate$12(ContactListActivity.java:47)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.sample.materialchipsinput.ContactListActivity$$Lambda$1.accept(Unknown Source)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err: 	... 24 more
04-25 23:35:34.811 10895-10895/com.pchmn.sample.materialchipsinput E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                     Process: com.pchmn.sample.materialchipsinput, PID: 10895
                                                                                     io.reactivex.exceptions.OnErrorNotImplementedException
                                                                                         at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
                                                                                         at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
                                                                                         at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
                                                                                         at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmitScalar(ObservableFlatMap.java:234)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:146)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139)
                                                                                         at io.reactivex.internal.operators.observable.ObservableBuffer$BufferExactObserver.onNext(ObservableBuffer.java:113)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmit(ObservableFlatMap.java:262)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$InnerObserver.onNext(ObservableFlatMap.java:559)
                                                                                         at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:112)
                                                                                         at io.reactivex.internal.operators.observable.ObservableConcatMap$SourceObserver$InnerObserver.onNext(ObservableConcatMap.java:249)
                                                                                         at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:265)
                                                                                         at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:184)
                                                                                         at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:64)
                                                                                         at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:49)
                                                                                         at android.app.Activity.dispatchRequestPermissionsResultToFragment(Activity.java:7120)
                                                                                         at android.app.Activity.dispatchActivityResult(Activity.java:6966)
                                                                                         at android.app.ActivityThread.deliverResults(ActivityThread.java:4162)
                                                                                         at android.app.ActivityThread.handleSendResult(ActivityThread.java:4209)
                                                                                         at android.app.ActivityThread.-wrap20(ActivityThread.java)
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571)
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                         at android.os.Looper.loop(Looper.java:241)
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:6223)
                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                                      Caused by: java.lang.NullPointerException
                                                                                         at java.text.RuleBasedCollator.compare(RuleBasedCollator.java:356)
                                                                                         at com.pchmn.materialchips.adapter.FilterableAdapter$1.compare(FilterableAdapter.java:66)
                                                                                         at com.pchmn.materialchips.adapter.FilterableAdapter$1.compare(FilterableAdapter.java:61)
                                                                                         at java.util.TimSort.countRunAndMakeAscending(TimSort.java:351)
                                                                                         at java.util.TimSort.sort(TimSort.java:230)
                                                                                         at java.util.Arrays.sort(Arrays.java:1523)
                                                                                         at java.util.Collections.sort(Collections.java:238)
                                                                                         at com.pchmn.materialchips.adapter.FilterableAdapter.<init>(FilterableAdapter.java:61)
                                                                                         at com.pchmn.materialchips.views.FilterableListView.build(FilterableListView.java:66)
                                                                                         at com.pchmn.materialchips.ChipsInput.setFilterableList(ChipsInput.java:342)
                                                                                         at com.pchmn.sample.materialchipsinput.ContactListActivity.getContactList(ContactListActivity.java:124)
                                                                                         at com.pchmn.sample.materialchipsinput.ContactListActivity.lambda$onCreate$12(ContactListActivity.java:47)
                                                                                         at com.pchmn.sample.materialchipsinput.ContactListActivity$$Lambda$1.accept(Unknown Source)
                                                                                         at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmitScalar(ObservableFlatMap.java:234) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:146) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableBuffer$BufferExactObserver.onNext(ObservableBuffer.java:113) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmit(ObservableFlatMap.java:262) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$InnerObserver.onNext(ObservableFlatMap.java:559) 
                                                                                         at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:112) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableConcatMap$SourceObserver$InnerObserver.onNext(ObservableConcatMap.java:249) 
                                                                                         at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:265) 
                                                                                         at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:184) 
                                                                                         at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:64) 
                                                                                         at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:49) 
                                                                                         at android.app.Activity.dispatchRequestPermissionsResultToFragment(Activity.java:7120) 
                                                                                         at android.app.Activity.dispatchActivityResult(Activity.java:6966) 
                                                                                         at android.app.ActivityThread.deliverResults(ActivityThread.java:4162) 
                                                                                         at android.app.ActivityThread.handleSendResult(ActivityThread.java:4209) 
                                                                                         at android.app.ActivityThread.-wrap20(ActivityThread.java) 
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571) 
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                         at android.os.Looper.loop(Looper.java:241) 
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:6223) 
                                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 

Could React Java be causing a problem here? I am testing on a Sony Xperia X Performance with Android Nougat. The library seems to work fine in the emulators. What could the problem be on my Android device?

@rayliverified
Copy link
Author

The earliest error occurs at Line 45 in ContactListActivity.java.
Error:

04-25 23:44:55.373 14712-14712/com.pchmn.sample.materialchipsinput W/System.err: at com.pchmn.sample.materialchipsinput.ContactListActivity.onCreate(ContactListActivity.java:45)

Code:

        // get contact list
        new RxPermissions(this)
                .request(Manifest.permission.READ_CONTACTS)
                .subscribe(granted -> {
                    if(granted && mContactList.size() == 0)
                        getContactList();
                });

@pchmn
Copy link
Owner

pchmn commented Apr 26, 2017

I didn't specify an onError handler, and I think that's why the exception occurred.
Please test this new sample apk with the fix, and tell me if it works :
https://github.com/pchmn/MaterialChipsInput/raw/master/docs/material-chips-input-sample-v1.0.4_2.apk

@rayliverified
Copy link
Author

The problem still persists with the same error log. What is RXPermissions? I have never seen it before and I don't know what it does.

@pchmn
Copy link
Owner

pchmn commented Apr 26, 2017

RxPermissions is a RxJava library for Android M runtime permissions. Here it is used to get read contacts permission.

So I looked at the logs you put, and the error is apparently caused by the fact that the contact list is null, but it seems weird.

It's difficult to debug without your phone haha. Test this apk and tell me if you see a toast message :
https://github.com/pchmn/MaterialChipsInput/raw/dev/docs/material-chips-input-sample-v1.0.4_3.apk

@rayliverified
Copy link
Author

Sorry, there is no toast message before the app crashes. This is really weird, why would the app crash after requesting permissions? Only after permissions are granted does the app fail. If permissions are not granted, the app fails only after the "Enter a name" box loses focus. If permissions are granted, clicking on
"Contact List Example" fails immediately.

Don't worry about it too much. Please only make it an issue if someelse reports this behavior too! Thanks for trying to debug this issue.

@pchmn
Copy link
Owner

pchmn commented Apr 27, 2017

Yes it's weird, maybe it is because of RxPermissions library. I will try to use the "normal way" of asking permission to see if it works better.

You don't have any issues on other apps with your Xperia ?

@rayliverified
Copy link
Author

rayliverified commented Apr 29, 2017

Not so far. My old development device bootlooped and this new phone isn't even a week old. All my apps are working correctly so far. I am not sure that requesting permissions than normally would solve the thought of it because the permission request dialogue appears correctly. Low priority issue until someone can confirm it's not specific to me. Very weird!

@pchmn
Copy link
Owner

pchmn commented May 2, 2017

Ok we'll see if anyone else will have the same issue.

@Dreamystify
Copy link

Dreamystify commented May 3, 2017

I have the same issue and I'm on an Xperia Z3, same permissions issue thought to be the problem. I have found its

getContactList();

and the line;

// pass contact list to chips input
mChipsInput.setFilterableList(mContactList);

Then

setFilterableList(List<? extends ChipInterface> list)

// and crashes on this line
mFilterableListView.build(mChipList, this, mFilterableListBackgroundColor, mFilterableListTextColor);

both mFilterableListBackgroundColor, mFilterableListTextColor are null values, not sure if that's the issue

@pchmn
Copy link
Owner

pchmn commented May 3, 2017

Ok so maybe the problem has to do with RxPermissions. I will make a sample app without this library and post the apk on this conversation. We'll see if it is better

@pchmn pchmn added the bug label May 3, 2017
@Dreamystify
Copy link

Dreamystify commented May 3, 2017

I've traced it back to the FilterableAdapter constructor and the following code

Collections.sort(chipList, new Comparator<ChipInterface>() {
            @Override
            public int compare(ChipInterface o1, ChipInterface o2) {
                Collator collator = Collator.getInstance(Locale.getDefault()); // <-- here
                collator.setStrength(Collator.PRIMARY);
                return collator.compare(o1.getLabel(), o2.getLabel());
            }
        });

its iterates through many of my 300+ contacts then crashes, I have a feeling its too time consuming for the amount of contacts, out of my league here lol

@pchmn
Copy link
Owner

pchmn commented May 3, 2017

Yeah ok thanks, maybe this is the sorting which is the responsible, and not RxPermissions haha. I don't know why I put the Collator inside the compare() function, it is recreated on each iteration, not very good.

This evening I will post an apk with the changes, hoping it will resolve the issue.

@Dreamystify
Copy link

Dreamystify commented May 4, 2017

Not a problem ;)

Edit:
It works when I sublist the contact list to around 100, so we are on the right track

chipList = chipList.subList(0, 100);

@rayliverified
Copy link
Author

Good to see that I'm not crazy :D

@pchmn
Copy link
Owner

pchmn commented May 4, 2017

You're not crazy haha.
I made the changes, here is the apk.
Tell me if it works.

@Dreamystify
Copy link

The app wouldn't install on my phone for some reason, did you just change the sorting code?

@pchmn
Copy link
Owner

pchmn commented May 5, 2017

Yeah I think it's because I built the apk on a different computer, so the signed key of the apk is different. Please just uninstall the app from your phone, then install the apk I posted.

@Dreamystify
Copy link

I did uninstall the original but it still failed

@pchmn
Copy link
Owner

pchmn commented May 5, 2017

Well that's weird. And you can install previous apks without failing ? This is just the last apk that fails ?

Because yes I just changed the sorting code

@Dreamystify
Copy link

I only ever built the app in android studio to my phone, never previously used the apk's

@pchmn
Copy link
Owner

pchmn commented May 5, 2017

Yes but now I make my changes on a different branch before merge it to the master. And I suppose that you forked or cloned the master branch, so the changes are not effective.

Did you try to install directly the last apk I posted on this conversation ?

@Dreamystify
Copy link

I haven't forked it, I will look for your changes and test that in a few moments, Yeah I tried your apk for the first time from this conversation.

@Dreamystify
Copy link

Dreamystify commented May 5, 2017

Ok I have 365 contacts in the list, when it gets to your sorting its crashing because its finding nulls in o1.getLabel(), o2.getLabel()

 mComparator = new Comparator<ChipInterface>() {
            @Override
            public int compare(ChipInterface o1, ChipInterface o2) {
                return mCollator.compare(o1.getLabel(), o2.getLabel());
            }
        };

So I ran the following code to eliminate the nulls just before the compare

List<ChipInterface> deleteCandidates = new ArrayList<>();
for (ChipInterface chip : chipList) {
     if (chip.getLabel() == null) {
         deleteCandidates.add(chip);
     }
}
chipList.removeAll(deleteCandidates);

and it works as fully expected, turns out, when I go into my contact list on the phone, at the very bottom of the list there are several entries flagged as "unknown" which I cant delete for some reason but seems to be added by outlook app. Might be good to filter these out of the list anyway for others who have rogue apps messing with their contact lists lol

pchmn added a commit that referenced this issue May 5, 2017
pchmn added a commit that referenced this issue May 5, 2017
@pchmn
Copy link
Owner

pchmn commented May 5, 2017

Ah great, that's why the app crashes, good job. I didn't know that's it possible to have a contact without a name !

I made the changes you suggest, and test it and it seems to work. If you could test this apk.

If it works we will be able to close this issue, finally !

@Dreamystify
Copy link

its crashing with your loop, presumably missing one via index changes

int count = 0;
for(ChipInterface chipInterface: chipList) {
    if(chipInterface.getLabel() == null)
        chipList.remove(count);
    count++;
}

but works with this one

List<ChipInterface> deleteCandidates = new ArrayList<>();
for (ChipInterface chip : chipList) {
    if (chip.getLabel() == null) {
        deleteCandidates.add(chip);
    }
}
chipList.removeAll(deleteCandidates);

I saw the nulls are random in the list and in groups at places, so whether your loop is skipping over one somewhere when the indexes of them change when the first is removed I'm not sure.

@rayliverified
Copy link
Author

Unfortunately, the last apk still crashes with the same error. I am not that familiar with RxJava so I'm sorry for not being able to do much 🤷‍♂️

@Dreamystify
Copy link

@searchy2 check your phones contact list to see if there are entries at the end of the list listed as "unknown", this is the reason for the error on mine

@rayliverified
Copy link
Author

rayliverified commented May 8, 2017

Hmm, there are some unknowns! I think this is an Xperia specific quirk as my previous phone had no unknowns.
screenshot_20170507-202029

@Dreamystify
Copy link

When you click on an unknown I find it to have my email from outlook in there, strange issue, and doesn't delete...

@rayliverified
Copy link
Author

My unknown contacts have nothing in them. No emails, no nothing! I am able to delete them however so there's that. Let me delete all my known contacts and then load up Material Chips to see if it fixes the crashing.

@rayliverified
Copy link
Author

I just tried deleting the unknowns and then using Material Chips. Still crashes :( Guess the unknowns are not the issue here.

pchmn added a commit that referenced this issue May 9, 2017
@pchmn
Copy link
Owner

pchmn commented May 9, 2017

Ok sorry for the delay.

Yeah you're right @DreamCatcha, an iterator must be used when removing item from a list while iterating over it. My loop wasn't correct. I made the changes.

Hope this one will work, here the apk

@rayliverified
Copy link
Author

No more crashes :D Great work @pchmn and @DreamCatcha

@DreamCatcha if you can confirm that there are no crashes with Unknown contacts, this issue can finally be closed 😆

@Dreamystify
Copy link

Yep that works fine now, thanks mate

@rayliverified
Copy link
Author

Nice! Great library with great support; so happy to see this problem fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants