I am using the Atlas service to access a database from my Flutter project. The debug build is working fine but in the release build the create()
method to instantiate the database object is giving some kind of error. I have added the INTERNET permission in the AndroidManifest.xml but the error is still there.
This is the log of the terminal running a release build
E/flutter (14697): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Failed host lookup: 'dns.google.com'
E/flutter (14697): #0 IOClient.send (package:http/src/io_client.dart:94)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697): #2 HttpUtils._get (package:basic_utils/src/HttpUtils.dart:24)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697): #3 HttpUtils.getForJson (package:basic_utils/src/HttpUtils.dart:49)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697): #4 DnsUtils.lookupRecord (package:basic_utils/src/DnsUtils.dart:33)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697): #5 decodeDnsSeedlist (package:mongo_dart/src/database/utils/dns_lookup.dart:19)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697): #6 Db.create (package:mongo_dart/src/database/db.dart:271)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697): #7 MongoDb.connect (package:student_portal/services/mongo_db.dart:21)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697): #8 main (package:student_portal/main.dart:13)
E/flutter (14697): <asynchronous suspension>
E/flutter (14697):
21th line of the mongo_db.dart is
_db = await Db.create(mongoURL);
and in the 13th line of main, I am calling the connect method
Future<void> connect() async {
_db = await Db.create(mongoURL);
await _db!.open(secure: true);
}