RxPermission在发布模式

时间:2018-02-22 15:54:20

标签: java android rx-java rx-java2 rxpermissions

我使用RxPermission库轻松处理运行时权限,

在我的应用中,我要求提供位置:

 rxPermissions
                .request(Manifest.permission.ACCESS_FINE_LOCATION)
                .subscribe(granted -> {
                    if (granted) {
                        boolean gpsEnabled, networkEnabled;

                        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                        if (locationManager != null) {
                            gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
                            networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

                            if (gpsEnabled && locationListenerGPS != null) {

                                locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0L, 0f, locationListenerGPS);
                            }

                            if (networkEnabled && locationListenerNetwork != null) {
                                locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0L, 0f, locationListenerNetwork);
                            }

                        }


                    } else {
                        Log.d("Access not granted", "no location");
                    }
                });

当我打开debug-apk它工作正常但当我尝试打开发布时,它崩溃了这个错误:

  

致命的例外:主要                                                      过程:com.magis.icbc,PID:19522                                                      java.lang.InternalError                                                          在d.c.d.b.s.a(UnsafeAccess.java:115)                                                          在d.c.d.b.r.(SpscArrayQueue.java:42)                                                          在d.c.a.d $ c。(OnSubscribeConcatMap.java:129)                                                          在d.c.a.d.a(OnSubscribeConcatMap.java:82)                                                          在d.c.a.d.a(OnSubscribeConcatMap.java:42)                                                          在d.d.a(Observable.java:10142)                                                          在d.c.a.k $ e.a(OperatorMerge.java:248)                                                          在d.c.a.k $ e.b(OperatorMerge.java:148)                                                          在d.c.a.h $ a.b(OnSubscribeMap.java:77)                                                          在d.c.a.k $ e.a(OperatorMerge.java:511)                                                          在d.c.a.k $ e.a(OperatorMerge.java:466)                                                          在d.c.a.k $ e.a(OperatorMerge.java:244)                                                          在d.c.a.k $ e.b(OperatorMerge.java:148)                                                          at d.c.a.e $ a.a(OnSubscribeFromArray.java:76)                                                          at d.c.a.e $ a.a(OnSubscribeFromArray.java:58)                                                          在d.i.a(Subscriber.java:211)                                                          在d.c.a.e.a(OnSubscribeFromArray.java:32)                                                          在d.c.a.e.a(OnSubscribeFromArray.java:24)                                                          在d.c.a.g.a(OnSubscribeLift.java:48)                                                          在d.c.a.g.a(OnSubscribeLift.java:30)                                                          在d.d.a(Observable.java:10142)                                                          在d.c.a.h.a(OnSubscribeMap.java:48)                                                          在d.c.a.h.a(OnSubscribeMap.java:33)                                                          在d.c.a.g.a(OnSubscribeLift.java:48)                                                          在d.c.a.g.a(OnSubscribeLift.java:30)                                                          在d.c.a.g.a(OnSubscribeLift.java:48)                                                          在d.c.a.g.a(OnSubscribeLift.java:30)                                                          在d.d.a(Observable.java:10142)                                                          在d.c.a.h.a(OnSubscribeMap.java:48)                                                          在d.c.a.h.a(OnSubscribeMap.java:33)                                                          在d.c.a.g.a(OnSubscribeLift.java:48)                                                          在d.c.a.g.a(OnSubscribeLift.java:30)                                                          在d.d.a(Observable.java:10238)                                                          在d.d.b(Observable.java:10205)                                                          在d.d.a(Observable.java:10010)                                                          在com.magis.icbc.ui.activities.SplashActivity.n(SplashActivity.java:222)                                                          在com.magis.icbc.ui.activities.SplashActivity.onCreate(SplashActivity.java:173)                                                          在android.app.Activity.performCreate(Activity.java:6876)                                                          在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)                                                          在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)                                                          在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)                                                          在android.app.ActivityThread.access $ 1100(ActivityThread.java:221)                                                          在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1794)                                                          在android.os.Handler.dispatchMessage(Handler.java:102)                                                          在android.os.Looper.loop(Looper.java:158)                                                          在android.app.ActivityThread.main(ActivityThread.java:7224)                                                          at java.lang.reflect.Method.invoke(Native Method)                                                          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1230)                                                          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)                                                       引起:java.lang.NoSuchFieldException:类中没有字段producerIndex   LD / C / d / B / R; (' d.c.d.b.r'的声明出现在   /data/app/com.magis.icbc-1/base.apk)                                                          at java.lang.Class.getDeclaredField(Native Method)                                                          在d.c.d.b.s.a(UnsafeAccess.java:112)

在这一行.subscribe(granted -> {

1 个答案:

答案 0 :(得分:2)

除了看似提供不安全访问之外,您似乎还有其中一个重命名字段并破坏反射的设备。尝试在RxJava初始化之前将rx.unsafe-disable系统属性设置为true来禁用此旧的RxJava功能。