I’m trying to build flutter application, and I’m encountering an error when running the app on Android. The same code works perfectly fine on iOS. The error message is:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PathNotFoundException: Cannot open file, path = ‘assets/crt/ca_bundle.crt’ (OS Error: No such file or directory, errno = 2)
The error is happening in the following class:
import 'dart:io';
import 'package:grpc/grpc.dart';
import 'package:injectable/injectable.dart';
import 'package:test/src/core/secure/secure_storage_service.dart';
import 'package:test/src/features/auth/data/interceptor/auth_interceptor.dart';
import '../../../../generated/user.pbgrpc.dart';
@Injectable()
class UserServiceHandler extends UserServiceClient {
UserServiceHandler(SecureStorageService storageService)
: super(
ClientChannel(
_host,
port: 50051,
options: ChannelOptions(
credentials: ChannelCredentials.secure(
certificates: File('assets/crt/ca_bundle.crt').readAsBytesSync(),
),
),
),
interceptors: [AuthInterceptor(storageService)],
options: CallOptions(
timeout: const Duration(seconds: 30),
),
);
static String get _host {
return 'mob.gopass.kz';
}
}
In my pubspec.yaml, I have listed the assets like this:
flutter:
uses-material-design: true
assets:
- assets/certs/
- assets/translations/
- assets/
- assets/icons/
- RiveAssets/
I’m not sure why the file cannot be found on Android but works fine on iOS.
Адильжан Омаркан is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.