Open yu75567218 opened 4 years ago
Hi @tbruyelle, I have the same crash happening when requesting an array of permissions, like this:
protected void requestPermission(final PermissionListener listener, String... permissions) {
ArrayList<String> permissionsList = new ArrayList<>();
for (String permission : permissions) {
if (!getPermissionsInstance().isGranted(permission)) {
permissionsList.add(permission);
}
}
int required = permissionsList.size();
if (required > 0) {
getPermissionsInstance().request(permissionsList.toArray(new String[required]))
.subscribe(new Observer<Boolean>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Boolean aBoolean) {
listener.granted(aBoolean);
}
@Override
public void onError(Throwable e) {
listener.granted(false);
}
@Override
public void onComplete() {
}
});
} else {
listener.granted(true);
}
}
And here's the stack trace:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Handler android.app.FragmentHostCallback.getHandler()' on a null object reference
at android.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:2008)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2061)
at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:822)
at com.tbruyelle.rxpermissions2.RxPermissions.getRxPermissionsFragment(RxPermissions.java:57)
at com.tbruyelle.rxpermissions2.RxPermissions.<init>(RxPermissions.java:44)
at com.myapplication.presentation.core.BaseActivity.getPermissionsInstance(BaseActivity.java:149)
at com.myapplication.presentation.core.BaseActivity.requestPermission(BaseActivity.java:472)
at com.myapplication.presentation.core.BaseActivity.openMediaGallery(BaseActivity.java:525)
at com.myapplication.presentation.core.composer.BaseSpecificActivity.access$400(BaseSpecificActivity.java:90)
at com.myapplication.presentation.core.composer.BaseSpecificActivity$12.onAddMedia(BaseSpecificActivity.java:710)
at com.mylibrary.Input$2.onClick(Input.java:417)
at android.view.View.performClick(View.java:7870)
at com.balysv.materialripple.MaterialRippleLayout$PerformClickEvent.run(MaterialRippleLayout.java:648)
at com.balysv.materialripple.MaterialRippleLayout$3.onAnimationEnd(MaterialRippleLayout.java:336)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:554)
at android.animation.AnimatorSet.endAnimation(AnimatorSet.java:1301)
at android.animation.AnimatorSet.doAnimationFrame(AnimatorSet.java:1086)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:994)
at android.view.Choreographer.doCallbacks(Choreographer.java:794)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:981)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7811)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
上下文环境不一致。操作的activity已经被销毁了
上下文环境不一致。操作的activity已经被销毁了
这是就一个bug 我也遇到了
Attempt to invoke virtual method 'android.os.Handler android.app.FragmentHostCallback.getHandler()' on a null object reference, 我目前用的这个版本: api 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar' 这个问题解决了吗?
phone: OPPO R17 /OPPO R15 android os: 8.1.0 log:
io.reactivex.exceptions.OnErrorNotImplementedException: The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Handler android.app.FragmentHostCallback.getHandler()' on a null object reference 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:77) at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:67) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:198) at android.app.ActivityThread.main(ActivityThread.java:7015) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Handler android.app.FragmentHostCallback.getHandler()' on a null object reference at android.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:1992) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2045) at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:799) at com.tbruyelle.rxpermissions2.RxPermissions.getRxPermissionsFragment(RxPermissions.java:57) at com.tbruyelle.rxpermissions2.RxPermissions.<init>(RxPermissions.java:44) at com.showfitness.commonlibrary.manager.MyManager.init(MyManager.java:143) at com.showfitness.commonlibrary.manager.MyManager.access$200(MyManager.java:59) at com.showfitness.commonlibrary.manager.MyManager$3.accept(MyManager.java:127) at com.showfitness.commonlibrary.manager.MyManager$3.accept(MyManager.java:124) at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63) ... 10 more java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Handler android.app.FragmentHostCallback.getHandler()' on a null object reference at android.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:1992) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2045) at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:799) at com.tbruyelle.rxpermissions2.RxPermissions.getRxPermissionsFragment(RxPermissions.java:57) at com.tbruyelle.rxpermissions2.RxPermissions.<init>(RxPermissions.java:44) at com.showfitness.commonlibrary.manager.MyManager.init(MyManager.java:143) at com.showfitness.commonlibrary.manager.MyManager.access$200(MyManager.java:59) at com.showfitness.commonlibrary.manager.MyManager$3.accept(MyManager.java:127) at com.showfitness.commonlibrary.manager.MyManager$3.accept(MyManager.java:124) at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:198) at android.app.ActivityThread.main(ActivityThread.java:7015) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)