Open yagizdo opened 1 year ago
Please show your source code
Please show your source code
Hi, sure
While this code works fine in most versions of ios and android (versions 12-13 I tried), it gives an error in android 11 version. I couldn't resolve.
Admin Scanner View :
class AdminScannerView extends StatefulWidget {
const AdminScannerView({Key? key, required this.isGiftScanner}) : super(key: key);
final bool isGiftScanner;
@override
State<AdminScannerView> createState() => _AdminScannerViewState();
}
class _AdminScannerViewState extends State<AdminScannerView> {
late final ScannerService _scannerService;
late final MobileScannerController _mobileScannerController;
AdminScanResponseModel? _adminScanResponseModel;
AdminGiftScanResponse? _adminGiftScanResponse;
Future<void> scanQRCode(String code) {
return _scannerService
.scanQRCode(code)
.then((value) {
setState(() {
_adminScanResponseModel = value;
});
})
.then((value) => AlertHelper.shared.showSuccessNotify(message: LocaleKeys.admin_scan_success_message.tr()))
.catchError((error) {
var exceptionMessage = ExceptionHandler.generateExceptionMessage(error);
AlertHelper.shared.showErrorNotify(message: exceptionMessage);
});
}
Future<void> scanGiftQRCode(String code) {
return _scannerService
.scanGiftQRCode(code)
.then((value) {
setState(() {
_adminGiftScanResponse = value;
});
})
.then((value) => AlertHelper.shared.showSuccessNotify(message: LocaleKeys.admin_scan_success_message.tr()))
.catchError((error) {
var exceptionMessage = ExceptionHandler.generateExceptionMessage(error);
AlertHelper.shared.showErrorNotify(message: exceptionMessage);
});
}
@override
void initState() {
super.initState();
_mobileScannerController = MobileScannerController(
detectionSpeed: DetectionSpeed.noDuplicates,
facing: CameraFacing.back,
torchEnabled: false,
autoStart: true,
);
_mobileScannerController.start();
_scannerService = getIt<ScannerService>();
}
@override
void dispose() {
_mobileScannerController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MainLayout(
extendBodyBehindAppBar: true,
appBar: PreferredSize(
preferredSize: Size.fromHeight(context.screenWidth * 0.3),
child: MainAppbar(
title: widget.isGiftScanner ? LocaleKeys.admin_gift_scanner_appbar_title.tr() : LocaleKeys.admin_scanner_appbar_title.tr(),
),
),
content: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
height10Per(context: context),
Column(
children: [
Text(widget.isGiftScanner ? LocaleKeys.admin_gift_scanner_title.tr() : LocaleKeys.admin_scanner_title.tr(),
style: AppTextStyle.adminScannerTitle(context: context)),
height3Per(context: context),
Text(
widget.isGiftScanner ? LocaleKeys.admin_gift_scanner_subtitle.tr() : LocaleKeys.admin_scanner_subtitle.tr(),
style: AppTextStyle.adminScannerSubtitle(context: context),
),
],
),
SizedBox(
height: context.screenWidth * 1,
child: Stack(
children: [
MobileScanner(
controller: _mobileScannerController,
onDetect: (barcode) {
if(widget.isGiftScanner) {
scanGiftQRCode(barcode.barcodes[0].rawValue!);
} else {
scanQRCode(barcode.barcodes[0].rawValue!);
}
},
),
const QRScannerOverlay(
overlayColour: AppColors.backgroundColor,
)
],
),
),
],
),
);
}
}
you can also check error on errorBuilder argument
I guess no need to call .start() function on initState since autoStart is already set to true
I guess no need to call .start() function on initState since autoStart is already set to true
I wasn't calling when I first got the error, then I tried. But I can try again. I'm trying now.
I updated my code as below, but the error builder crashed with the same error without even working.
class AdminScannerView extends StatefulWidget {
const AdminScannerView({Key? key, required this.isGiftScanner}) : super(key: key);
final bool isGiftScanner;
@override
State<AdminScannerView> createState() => _AdminScannerViewState();
}
class _AdminScannerViewState extends State<AdminScannerView> {
late final ScannerService _scannerService;
late final MobileScannerController _mobileScannerController;
AdminScanResponseModel? _adminScanResponseModel;
AdminGiftScanResponse? _adminGiftScanResponse;
Future<void> scanQRCode(String code) {
return _scannerService
.scanQRCode(code)
.then((value) {
setState(() {
_adminScanResponseModel = value;
});
})
.then((value) => AlertHelper.shared.showSuccessNotify(message: LocaleKeys.admin_scan_success_message.tr()))
.catchError((error) {
var exceptionMessage = ExceptionHandler.generateExceptionMessage(error);
AlertHelper.shared.showErrorNotify(message: exceptionMessage);
});
}
Future<void> scanGiftQRCode(String code) {
return _scannerService
.scanGiftQRCode(code)
.then((value) {
setState(() {
_adminGiftScanResponse = value;
});
})
.then((value) => AlertHelper.shared.showSuccessNotify(message: LocaleKeys.admin_scan_success_message.tr()))
.catchError((error) {
var exceptionMessage = ExceptionHandler.generateExceptionMessage(error);
AlertHelper.shared.showErrorNotify(message: exceptionMessage);
});
}
@override
void initState() {
super.initState();
_mobileScannerController = MobileScannerController(
detectionSpeed: DetectionSpeed.noDuplicates,
facing: CameraFacing.back,
torchEnabled: false,
autoStart: true,
);
_scannerService = getIt<ScannerService>();
}
@override
void dispose() {
_mobileScannerController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MainLayout(
extendBodyBehindAppBar: true,
appBar: PreferredSize(
preferredSize: Size.fromHeight(context.screenWidth * 0.3),
child: MainAppbar(
title: widget.isGiftScanner ? LocaleKeys.admin_gift_scanner_appbar_title.tr() : LocaleKeys.admin_scanner_appbar_title.tr(),
),
),
content: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
height10Per(context: context),
Column(
children: [
Text(widget.isGiftScanner ? LocaleKeys.admin_gift_scanner_title.tr() : LocaleKeys.admin_scanner_title.tr(),
style: AppTextStyle.adminScannerTitle(context: context)),
height3Per(context: context),
Text(
widget.isGiftScanner ? LocaleKeys.admin_gift_scanner_subtitle.tr() : LocaleKeys.admin_scanner_subtitle.tr(),
style: AppTextStyle.adminScannerSubtitle(context: context),
),
],
),
SizedBox(
height: context.screenWidth * 1,
child: Stack(
children: [
MobileScanner(
controller: _mobileScannerController,
onDetect: (barcode) {
if(widget.isGiftScanner) {
scanGiftQRCode(barcode.barcodes[0].rawValue!);
} else {
scanQRCode(barcode.barcodes[0].rawValue!);
}
},
errorBuilder: (context, error, child) {
return Center(
child: Text(
error.toString(),
style: TextStyle(color: Colors.red),
),
);
},
),
const QRScannerOverlay(
overlayColour: AppColors.backgroundColor,
)
],
),
),
],
),
);
}
}
change error.toString() to error.errorDetails.message
change error.toString() to error.errorDetails.message
I updated the code as below. But it crashes again with the same error. I can't even see the error returning from Errorbuilder.
Code :
MobileScanner(
controller: _mobileScannerController,
onDetect: (barcode) {
if(widget.isGiftScanner) {
scanGiftQRCode(barcode.barcodes[0].rawValue!);
} else {
scanQRCode(barcode.barcodes[0].rawValue!);
}
},
errorBuilder: (context, error, child) {
return Center(
child: Text(
error.errorDetails.toString(),
style: TextStyle(color: Colors.red),
),
);
},
),
Error :
D/TransportRuntime.SQLiteEventStore( 7709): Storing event with priority=DEFAULT, name=FIREBASE_ML_SDK for destination cct
I/CameraManagerGlobal( 7709): Connecting to camera service
D/TransportRuntime.JobInfoScheduler( 7709): Upload for context TransportContext(cct, DEFAULT, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning...
D/CameraRepository( 7709): Added camera: 1
I/Camera2CameraInfo( 7709): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 7709): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 7709): Camera LensFacing verification failed, existing cameras: [Camera@97d5c48[id=1]]
W/CameraX ( 7709): Retry init. Start time 1764394 current time 1764449
W/CameraX ( 7709): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 7709): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 7709): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 7709): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 7709): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 7709): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 7709): ... 5 more
D/CameraRepository( 7709): Added camera: 1
I/Camera2CameraInfo( 7709): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 7709): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 7709): Camera LensFacing verification failed, existing cameras: [Camera@9709519[id=1]]
W/CameraX ( 7709): Retry init. Start time 1764394 current time 1764977
W/CameraX ( 7709): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 7709): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 7709): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 7709): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 7709): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 7709): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 7709): ... 5 more
D/CameraRepository( 7709): Added camera: 1
I/Camera2CameraInfo( 7709): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 7709): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 7709): Camera LensFacing verification failed, existing cameras: [Camera@438b6b6[id=1]]
W/CameraX ( 7709): Retry init. Start time 1764394 current time 1765494
W/CameraX ( 7709): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 7709): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 7709): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 7709): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 7709): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 7709): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 7709): ... 5 more
D/CameraRepository( 7709): Added camera: 1
I/Camera2CameraInfo( 7709): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 7709): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 7709): Camera LensFacing verification failed, existing cameras: [Camera@ac9eaf[id=1]]
W/CameraX ( 7709): Retry init. Start time 1764394 current time 1766013
W/CameraX ( 7709): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 7709): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 7709): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 7709): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 7709): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 7709): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 7709): ... 5 more
D/CameraRepository( 7709): Added camera: 1
I/Camera2CameraInfo( 7709): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 7709): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 7709): Camera LensFacing verification failed, existing cameras: [Camera@d50fd54[id=1]]
W/CameraX ( 7709): Retry init. Start time 1764394 current time 1766564
W/CameraX ( 7709): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 7709): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 7709): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 7709): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 7709): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 7709): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 7709): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 7709): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 7709): ... 5 more
D/CameraRepository( 7709): Added camera: 1
I/Camera2CameraInfo( 7709): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 7709): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 7709): Camera LensFacing verification failed, existing cameras: [Camera@b5776b5[id=1]]
E/CameraX ( 7709): The device might underreport the amount of the cameras. Finish the initialize task since we are already reaching the maximum number of retries.
D/AndroidRuntime( 7709): Shutting down VM
E/AndroidRuntime( 7709): FATAL EXCEPTION: main
E/AndroidRuntime( 7709): Process: com.freddo.freddo_mobile_app, PID: 7709
E/AndroidRuntime( 7709): java.lang.IllegalArgumentException: Provided camera selector unable to resolve a camera for the given use case
E/AndroidRuntime( 7709): at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:476)
E/AndroidRuntime( 7709): at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:363)
E/AndroidRuntime( 7709): at dev.steenbakker.mobile_scanner.MobileScanner.start$lambda-11(MobileScanner.kt:191)
E/AndroidRuntime( 7709): at dev.steenbakker.mobile_scanner.MobileScanner.$r8$lambda$lZ4oz9drwcwj0DZn-HVtxaofOTE(Unknown Source:0)
E/AndroidRuntime( 7709): at dev.steenbakker.mobile_scanner.MobileScanner$$ExternalSyntheticLambda1.run(Unknown Source:14)
E/AndroidRuntime( 7709): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime( 7709): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 7709): at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 7709): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 7709): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 7709): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 7709): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process ( 7709): Sending signal. PID: 7709 SIG: 9
Lost connection to device.
try to call the error.errorDetails.message in log. add this code before return: log(error.errorDetails.message );
try to call the error.errorDetails.message in log. add this code before return: log(error.errorDetails.message );
Still same.
Code :
errorBuilder: (context, error, child) {
print('Scanner Error : ${error.errorDetails.toString()}');
return Center(
child: Text(
error.errorDetails.toString(),
style: TextStyle(color: Colors.red),
),
);
},
),
Error :
Launching lib/main.dart on sdk gphone arm64 in debug mode...
Running Gradle task 'assembleDebug'...
β Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app-debug.apk...
Debug service listening on ws://127.0.0.1:64699/Ua2qzHEzw-w=/ws
Syncing files to device sdk gphone arm64...
I/flutter ( 8632): [π Easy Localization] [DEBUG] Localization initialized
[GETX] Instance "NetworkController" has been created
[GETX] Instance "NetworkController" has been initialized
I/flutter ( 8632): [π Easy Localization] [DEBUG] Start
I/flutter ( 8632): [π Easy Localization] [DEBUG] Init state
I/flutter ( 8632): [π Easy Localization] [DEBUG] Build
I/flutter ( 8632): [π Easy Localization] [DEBUG] Init Localization Delegate
I/flutter ( 8632): [π Easy Localization] [DEBUG] Init provider
[GETX] Instance "GetMaterialController" has been created
[GETX] Instance "GetMaterialController" has been initialized
I/flutter ( 8632): [π Easy Localization] [DEBUG] Load Localization Delegate
D/TransportRuntime.CctTransportBackend( 8632): Making request to: https://firebaselogging.googleapis.com/v0cc/log/batch?format=json_proto3
I/TransportRuntime.CctTransportBackend( 8632): Status Code: 200
I/TransportRuntime.CctTransportBackend( 8632): Content-Type: application/json; charset=UTF-8
I/TransportRuntime.CctTransportBackend( 8632): Content-Encoding: gzip
D/TransportRuntime.SQLiteEventStore( 8632): Storing event with priority=DEFAULT, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler( 8632): Scheduling upload for context TransportContext(cct, DEFAULT, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) with jobId=-1605293984 in 871873ms(Backend next call timestamp 1686216151533). Attempt 1
I/CameraManagerGlobal( 8632): Connecting to camera service
D/CameraRepository( 8632): Added camera: 1
I/Camera2CameraInfo( 8632): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 8632): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 8632): Camera LensFacing verification failed, existing cameras: [Camera@22e6a50[id=1]]
W/CameraX ( 8632): Retry init. Start time 2314300 current time 2314379
W/CameraX ( 8632): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 8632): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 8632): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 8632): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 8632): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 8632): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 8632): ... 5 more
D/CameraRepository( 8632): Added camera: 1
I/Camera2CameraInfo( 8632): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 8632): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 8632): Camera LensFacing verification failed, existing cameras: [Camera@610c381[id=1]]
W/CameraX ( 8632): Retry init. Start time 2314300 current time 2314925
W/CameraX ( 8632): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 8632): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 8632): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 8632): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 8632): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 8632): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 8632): ... 5 more
D/CameraRepository( 8632): Added camera: 1
I/Camera2CameraInfo( 8632): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 8632): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 8632): Camera LensFacing verification failed, existing cameras: [Camera@4a329fe[id=1]]
W/CameraX ( 8632): Retry init. Start time 2314300 current time 2315462
W/CameraX ( 8632): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 8632): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 8632): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 8632): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 8632): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 8632): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 8632): ... 5 more
D/CameraRepository( 8632): Added camera: 1
I/Camera2CameraInfo( 8632): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 8632): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 8632): Camera LensFacing verification failed, existing cameras: [Camera@f25b157[id=1]]
W/CameraX ( 8632): Retry init. Start time 2314300 current time 2316003
W/CameraX ( 8632): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 8632): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 8632): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 8632): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 8632): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 8632): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 8632): ... 5 more
D/CameraRepository( 8632): Added camera: 1
I/Camera2CameraInfo( 8632): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 8632): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 8632): Camera LensFacing verification failed, existing cameras: [Camera@19ec7dc[id=1]]
W/CameraX ( 8632): Retry init. Start time 2314300 current time 2316526
W/CameraX ( 8632): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 8632): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 8632): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 8632): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 8632): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 8632): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 8632): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 8632): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 8632): ... 5 more
D/CameraRepository( 8632): Added camera: 1
I/Camera2CameraInfo( 8632): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 8632): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 8632): Camera LensFacing verification failed, existing cameras: [Camera@2f8b79d[id=1]]
E/CameraX ( 8632): The device might underreport the amount of the cameras. Finish the initialize task since we are already reaching the maximum number of retries.
D/AndroidRuntime( 8632): Shutting down VM
E/AndroidRuntime( 8632): FATAL EXCEPTION: main
E/AndroidRuntime( 8632): Process: com.freddo.freddo_mobile_app, PID: 8632
E/AndroidRuntime( 8632): java.lang.IllegalArgumentException: Provided camera selector unable to resolve a camera for the given use case
E/AndroidRuntime( 8632): at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:476)
E/AndroidRuntime( 8632): at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:363)
E/AndroidRuntime( 8632): at dev.steenbakker.mobile_scanner.MobileScanner.start$lambda-11(MobileScanner.kt:191)
E/AndroidRuntime( 8632): at dev.steenbakker.mobile_scanner.MobileScanner.$r8$lambda$lZ4oz9drwcwj0DZn-HVtxaofOTE(Unknown Source:0)
E/AndroidRuntime( 8632): at dev.steenbakker.mobile_scanner.MobileScanner$$ExternalSyntheticLambda1.run(Unknown Source:14)
E/AndroidRuntime( 8632): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime( 8632): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 8632): at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 8632): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 8632): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8632): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 8632): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process ( 8632): Sending signal. PID: 8632 SIG: 9
Lost connection to device.
add the .message
add the .message
I missed it, sorry. I just added it and tested it.
Code :
MobileScanner(
controller: _mobileScannerController,
onDetect: (barcode) {
if(widget.isGiftScanner) {
scanGiftQRCode(barcode.barcodes[0].rawValue!);
} else {
scanQRCode(barcode.barcodes[0].rawValue!);
}
},
errorBuilder: (context, error, child) {
print('Scanner Error : ${error.errorDetails?.message.toString()}');
return Center(
child: Text(
error.errorDetails?.message.toString() ?? '',
style: TextStyle(color: Colors.red),
),
);
},
),
Error :
I/eddo_mobile_ap( 9656): Waiting for a blocking GC ProfileSaver
D/TransportRuntime.SQLiteEventStore( 9656): Storing event with priority=DEFAULT, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler( 9656): Upload for context TransportContext(cct, DEFAULT, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning...
I/CameraManagerGlobal( 9656): Connecting to camera service
D/CameraRepository( 9656): Added camera: 1
I/Camera2CameraInfo( 9656): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 9656): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 9656): Camera LensFacing verification failed, existing cameras: [Camera@bb96fa9[id=1]]
W/CameraX ( 9656): Retry init. Start time 2977881 current time 2977906
W/CameraX ( 9656): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 9656): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 9656): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 9656): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 9656): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 9656): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 9656): ... 5 more
D/CameraRepository( 9656): Added camera: 1
I/Camera2CameraInfo( 9656): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 9656): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 9656): Camera LensFacing verification failed, existing cameras: [Camera@75a4006[id=1]]
W/CameraX ( 9656): Retry init. Start time 2977881 current time 2978432
W/CameraX ( 9656): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 9656): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 9656): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 9656): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 9656): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 9656): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 9656): ... 5 more
D/CameraRepository( 9656): Added camera: 1
I/Camera2CameraInfo( 9656): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 9656): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 9656): Camera LensFacing verification failed, existing cameras: [Camera@88c47bf[id=1]]
W/CameraX ( 9656): Retry init. Start time 2977881 current time 2978941
W/CameraX ( 9656): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 9656): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 9656): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 9656): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 9656): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 9656): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 9656): ... 5 more
D/CameraRepository( 9656): Added camera: 1
I/Camera2CameraInfo( 9656): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 9656): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 9656): Camera LensFacing verification failed, existing cameras: [Camera@8348324[id=1]]
W/CameraX ( 9656): Retry init. Start time 2977881 current time 2979444
W/CameraX ( 9656): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 9656): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 9656): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 9656): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 9656): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 9656): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 9656): ... 5 more
D/CameraRepository( 9656): Added camera: 1
I/Camera2CameraInfo( 9656): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 9656): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 9656): Camera LensFacing verification failed, existing cameras: [Camera@adc7245[id=1]]
W/CameraX ( 9656): Retry init. Start time 2977881 current time 2979951
W/CameraX ( 9656): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 9656): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:342)
W/CameraX ( 9656): at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(Unknown Source:10)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 9656): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 9656): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 9656): Caused by: java.lang.IllegalArgumentException: No available camera can be found
W/CameraX ( 9656): at androidx.camera.core.CameraSelector.select(CameraSelector.java:82)
W/CameraX ( 9656): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:83)
W/CameraX ( 9656): ... 5 more
D/CameraRepository( 9656): Added camera: 1
I/Camera2CameraInfo( 9656): Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_FULL
D/CameraValidator( 9656): Verifying camera lens facing on emulator_arm64, lensFacingInteger: null
E/CameraValidator( 9656): Camera LensFacing verification failed, existing cameras: [Camera@9a085f2[id=1]]
E/CameraX ( 9656): The device might underreport the amount of the cameras. Finish the initialize task since we are already reaching the maximum number of retries.
D/AndroidRuntime( 9656): Shutting down VM
E/AndroidRuntime( 9656): FATAL EXCEPTION: main
E/AndroidRuntime( 9656): Process: com.freddo.freddo_mobile_app, PID: 9656
E/AndroidRuntime( 9656): java.lang.IllegalArgumentException: Provided camera selector unable to resolve a camera for the given use case
E/AndroidRuntime( 9656): at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:476)
E/AndroidRuntime( 9656): at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:363)
E/AndroidRuntime( 9656): at dev.steenbakker.mobile_scanner.MobileScanner.start$lambda-11(MobileScanner.kt:191)
E/AndroidRuntime( 9656): at dev.steenbakker.mobile_scanner.MobileScanner.$r8$lambda$lZ4oz9drwcwj0DZn-HVtxaofOTE(Unknown Source:0)
E/AndroidRuntime( 9656): at dev.steenbakker.mobile_scanner.MobileScanner$$ExternalSyntheticLambda1.run(Unknown Source:14)
E/AndroidRuntime( 9656): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime( 9656): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 9656): at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 9656): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 9656): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9656): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 9656): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process ( 9656): Sending signal. PID: 9656 SIG: 9
Lost connection to device.
I'm not really sure if this can be related to this issue, actually I have an UMIDIGI F3 with Android 11 which, when it try to access to camera, miserably fail.
The code I use is almost the same from the examples, but I think in this case the issue is with the device itself.
/CameraValidator( 8287): Verifying camera lens facing on A13, lensFacingInteger: null
E/CameraValidator( 8287): Camera LensFacing verification failed, existing cameras: [Camera@7bdbfc6[id=0], Camera@8d53d9[id=1], Camera@28c6138[id=3], Camera@7887113[id=4]]
W/CameraX ( 8287): Retry init. Start time 11057785 current time 11060109
W/CameraX ( 8287): androidx.camera.core.impl.CameraValidator$CameraIdListIncorrectException: Expected camera missing from device.
W/CameraX ( 8287): at androidx.camera.core.impl.CameraValidator.validateCameras(CameraValidator.java:97)
W/CameraX ( 8287): at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:334)
W/CameraX ( 8287): at androidx.camera.core.CameraX$$ExternalSyntheticLambda3.run(Unknown Source:10)
W/CameraX ( 8287): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/CameraX ( 8287): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/CameraX ( 8287): at java.lang.Thread.run(Thread.java:923)
W/CameraX ( 8287): Caused by: java.lang.IllegalArgumentException: The given lens facing integer: 255 can not be recognized.
W/CameraX ( 8287): at androidx.camera.camera2.internal.LensFacingUtil.getCameraSelectorLensFacing(LensFacingUtil.java:56)
W/CameraX ( 8287): at androidx.camera.camera2.internal.Camera2CameraInfoImpl.getLensFacing(Camera2CameraInfoImpl.java:198)
W/CameraX ( 8287): at androidx.camera.core.impl.LensFacingCameraFilter.filter(LensFacingCameraFilter.java:48)
W/CameraX ( 8287): at androidx.camera.core.CameraSelector.filter(CameraSelector.java:128)
W/CameraX ( 8287): at androidx.camera.core.CameraSelector.filter(CameraSelector.java:153)
Android 11 crash issue still persists. None of the solutions I tried worked.
Steps :
Console Log: