Я следовал Сделайте снимок с помощью камеры в кулинарной книге. Я не получаю никаких ошибок при сборке, в приложении все работает нормально, но я получаю это сообщение при переходе к моему CameraHandler
виджету. Он запрашивает разрешение на использование камеры и запись звука, но после этого я вижу только индикатор прогресса.
E/libc (32251): Access denied finding property
"persist.vendor.camera.privapp.list"
W/gmess.pg_survey(32251): type=1400 audit(0.0:203606): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=18586 scontext=u:r:untrusted_app:s0:c13,c257,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
W/Binder:32251_3(32251): type=1400 audit(0.0:203607): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=18586 scontext=u:r:untrusted_app:s0:c13,c257,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
E/libc (32251): Access denied finding property "vendor.camera.aux.packagelist"
E/libc (32251): Access denied finding property "vendor.camera.aux.packagelist"
W/Binder:32251_3(32251): type=1400 audit(0.0:203608): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=18586 scontext=u:r:untrusted_app:s0:c13,c257,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
Вот мой виджет CameraHandler
:
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' show join;
import 'package:path_provider/path_provider.dart';
class CameraHandler extends StatefulWidget {
final CameraDescription camera;
const CameraHandler({
Key key,
@required this.camera,
}) : super(key: key);
@override
_CameraHandlerState createState() => _CameraHandlerState();
}
class _CameraHandlerState extends State<CameraHandler> {
CameraController _controller;
Future<void> _initControllerFuture;
@override
void initState() {
super.initState();
_controller = CameraController(widget.camera, ResolutionPreset.medium);
_initControllerFuture = _controller.initialize();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Take pictures of PG')),
body: FutureBuilder<void>(
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return CameraPreview(_controller);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.camera_alt),
onPressed: () async {
try {
await _initControllerFuture;
final path = join(
(await getTemporaryDirectory()).path,
'${DateTime.now()}.png',
);
await _controller.takePicture(path);
print('Took a picture from Camera!!');
} catch (e) {
print('Camera Error: ' + e);
}
},
),
);
}
}
И вотмой AndroidManifest.xml
со всеми необходимыми разрешениями:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="pg_survey"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Где я иду не так, пожалуйста, помогите!