使用产品:iserver 9d 操作系统:win10 x64 数据类型: 文件型 问题详细描述:androidstudio 应用添加了权限,复制了SampleData目录到设备,复制了授权到手机目录,在调用完
Environment.initialization(this);时报空指针错误
如下图
您好,1.在Android6.0设备以上运行需要设置动态权限,请问一下你是否对app开启了动态权限呢?
2.在grandle文件中加上
sourceSets { main { jniLibs.srcDirs = ['libs'] } }
sourceSets { main{ java.srcDirs = ['src/main/java', 'src/main/aidl'] resources.srcDirs = ['src/main/java', 'src/main/aidl'] aidl.srcDirs = ['src/main/aidl'] res.srcDirs = ['src/main/res'] jniLibs.srcDirs = ['src/main/libs','libs'] } }
动态权限也加了,用的hipermission,
/** * 12. 检查APP所需权限 * */ public void checkPermissions() { if (Build.VERSION.SDK_INT >= 23) { List<PermissionItem> permissionItems = new ArrayList<PermissionItem>(); permissionItems.add(new PermissionItem(Manifest.permission.READ_PHONE_STATE, "设备状态", R.drawable.permission_ic_phone)); permissionItems.add(new PermissionItem(Manifest.permission.WRITE_EXTERNAL_STORAGE, "SD存储卡", R.drawable.permission_ic_storage)); permissionItems.add(new PermissionItem(Manifest.permission.ACCESS_FINE_LOCATION, "位置服务", R.drawable.permission_ic_location)); // permissionItems.add(new PermissionItem(Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, "文件管理", R.drawable.permission_ic_location)); permissionItems.add(new PermissionItem(Manifest.permission.INTERNET, "网络服务", R.drawable.permission_ic_location)); permissionItems.add(new PermissionItem(Manifest.permission.ACCESS_NETWORK_STATE, "网络状态", R.drawable.permission_ic_location)); permissionItems.add(new PermissionItem(Manifest.permission.ACCESS_WIFI_STATE, "WIFI状态", R.drawable.permission_ic_location)); // permissionItems.add(new PermissionItem(Manifest.permission.WRITE_SETTINGS, "创建文件夹", R.drawable.permission_ic_phone)); permissionItems.add(new PermissionItem(Manifest.permission.CHANGE_WIFI_STATE, "位置服务", R.drawable.permission_ic_phone)); HiPermission.create(this) .permissions(permissionItems) .checkMutiPermission(new PermissionCallback() { @Override public void onClose() { Log.e(TAG, "用户取消权限申请"); finish(); } @Override public void onFinish() { Log.e(TAG, "所有权限申请完成"); initView(); } @Override public void onDeny(String permission, int position) { Log.e(TAG, "用户拒绝权限申请:" + permission); } @Override public void onGuarantee(String permission, int position) { Log.e(TAG, "用户允许权限申请:" + permission); } }); } else{ initView(); } }
调试调用在Environment.initialization(this);方法的如下函数中
checkAndLoadLibrary64(var0);
执行通过trycatch捕获到的错误是
java.lang.NullPointerException: Attempt to get length of null array