1

我使用 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 时,它运行良好,但是当我尝试打开 release apk 时,它会因以下错误而崩溃:

在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 处运行(ZygoteInit.java:1230) 原因:java.lang.NoSuchFieldException:Ld/c/d/b/r 类中没有字段 producerIndex ; ('dcdbr' 的声明出现在 /data/app/com.magis.icbc-1/base.apk)的 java.lang.Class.getDeclaredField(Native Method) at dcdbsa(UnsafeAccess.java:112) Ld/c/d/b/r 类中没有字段 producerIndex;('dcdbr' 的声明出现在 /data/app/com.magis.icbc-1/base.apk)的 java.lang.Class.getDeclaredField(Native Method) at dcdbsa(UnsafeAccess.java:112) Ld/c/d/b/r 类中没有字段 producerIndex;('dcdbr' 的声明出现在 /data/app/com.magis.icbc-1/base.apk)的 java.lang.Class.getDeclaredField(Native Method) at dcdbsa(UnsafeAccess.java:112)

正好在这条线上 .subscribe(granted -> {

4

1 回答 1

2

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

于 2018-02-22T16:00:00.497 回答