Flutter connect with BLE Device even after calling connect methods - android

I was trying to connect my application to bluetooth devices (which is ESP32) using flutter_blue_plus library. So in ESP32, there is a firmware that advertize bluetooth signal and my application should connect to that device when I press "CONNECT" button.
Here is the code for my connect button :
onPressed: () {
flutterBlue.startScan(timeout: Duration(seconds: 4));
var subscription = flutterBlue.scanResults.listen((results) async {
for (ScanResult r in results) {
print('${r.device.name} found! rssi: ${r.rssi}');
if (_id_controller.text == '${r.device.name}' && _id_controller.text != '') {
flutterBlue.stopScan();
r.device.connect();
print('${_id_controller.text} same with ${r.device.name}');
print(flutterBlue.connectedDevices);
List<BluetoothService> services = await r.device.discoverServices();
services.forEach((service) async {
var characteristics = service.characteristics;
for(BluetoothCharacteristic c in characteristics) {
List<int> value = await c.read();
print(value);
await c.write([73, 77, 65, 77]);
}
});
}
}
});
flutterBlue.stopScan();
},
so there after I press that "CONNECT" button, it is not trying to discover the services. After doing the debug processing, it said that my apps is not connected at all. Here is the dlog for my debug result.
I/flutter (28832): found! rssi: -49
I/flutter (28832): GNG000001 found! rssi: -92
W/provisioningap(28832): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
D/BluetoothAdapter(28832): isLeEnabled(): ON
D/BluetoothLeScanner(28832): onScannerRegistered() - status=0 scannerId=8 mScannerId=0
I/flutter (28832): GNG000001 same with GNG000001
D/BluetoothAdapter(28832): isLeEnabled(): ON
I/flutter (28832): Instance of 'Future<List<BluetoothDevice>>'
W/provisioningap(28832): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
E/BluetoothGatt(28832):
E/BluetoothGatt(28832): android.os.DeadObjectException
E/BluetoothGatt(28832): at android.os.BinderProxy.transactNative(Native Method)
E/BluetoothGatt(28832): at android.os.BinderProxy.transact(BinderProxy.java:543)
E/BluetoothGatt(28832): at android.bluetooth.IBluetoothGatt$Stub$Proxy.clientConnect(IBluetoothGatt.java:1847)
E/BluetoothGatt(28832): at android.bluetooth.BluetoothGatt.connect(BluetoothGatt.java:915)
E/BluetoothGatt(28832): at com.boskokg.flutter_blue_plus.FlutterBluePlusPlugin.lambda$onMethodCall$3$com-boskokg-flutter_blue_plus-FlutterBluePlusPlugin(FlutterBluePlusPlugin.java:342)
E/BluetoothGatt(28832): at com.boskokg.flutter_blue_plus.FlutterBluePlusPlugin$$ExternalSyntheticLambda5.op(Unknown Source:6)
E/BluetoothGatt(28832): at com.boskokg.flutter_blue_plus.FlutterBluePlusPlugin.ensurePermissionBeforeAction(FlutterBluePlusPlugin.java:727)
E/BluetoothGatt(28832): at com.boskokg.flutter_blue_plus.FlutterBluePlusPlugin.onMethodCall(FlutterBluePlusPlugin.java:315)
E/BluetoothGatt(28832): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/BluetoothGatt(28832): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/BluetoothGatt(28832): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/BluetoothGatt(28832): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/BluetoothGatt(28832): at android.os.Handler.handleCallback(Handler.java:883)
E/BluetoothGatt(28832): at android.os.Handler.dispatchMessage(Handler.java:100)
E/BluetoothGatt(28832): at android.os.Looper.loop(Looper.java:264)
E/BluetoothGatt(28832): at android.app.ActivityThread.main(ActivityThread.java:7581)
E/BluetoothGatt(28832): at java.lang.reflect.Method.invoke(Native Method)
E/BluetoothGatt(28832): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/BluetoothGatt(28832): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
D/FlutterBluePlugin(28832): mDevices size: 1
D/BluetoothAdapter(28832): isLeEnabled(): ON
D/BluetoothLeScanner(28832): could not find callback wrapper
E/flutter (28832): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(reconnect_error, error when reconnecting to device, null, null)
E/flutter (28832): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
E/flutter (28832): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
E/flutter (28832): <asynchronous suspension>
E/flutter (28832): #2 BluetoothDevice.connect (package:flutter_blue_plus/src/bluetooth_device.dart:39:5)
E/flutter (28832): <asynchronous suspension>
E/flutter (28832):
E/flutter (28832): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: Cannot discoverServices while device is not connected. State == BluetoothDeviceState.disconnected
E/flutter (28832):
I think there is an issue at my "CONNECT" button. But I am not really sure. Here is the full code. Really need help for this. Thanks.

Related

[flutter/FCM]problem receiving notification

I'm using flutter and Firebasemessaging to send and receive notification and the plugging FlutterLocalNotifications to display them.
but when I receive the notification I get the error :
D/FLTFireMsgReceiver(23943): broadcast received for message
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): Failed to handle method call
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.setSmallIcon(FlutterLocalNotificationsPlugin.java:308)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:219)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1013)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1354)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1230)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:319)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at android.os.Looper.loop(Looper.java:223)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#dexterous.com/flutter/local_notifications(23943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (23943): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
E/flutter (23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.setSmallIcon(FlutterLocalNotificationsPlugin.java:308)
E/flutter (23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:219)
E/flutter (23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1013)
E/flutter (23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1354)
E/flutter (23943): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1230)
E/flutter (23943): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/flutter (23943): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter (23943): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:319)
E/flutter (23943): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
E/flutter (23943): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (23943): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (23943): at android.os.Looper.loop(Looper.java:223)
E/flutter (23943): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/flutter (23943): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (23943): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/flutter (23943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (23943): )
E/flutter (23943): #0 StandardMethodCodec.decodeEnvelope
E/flutter (23943): #1 MethodChannel._invokeMethod
E/flutter (23943): <asynchronous suspension>
E/flutter (23943): #2 FlutterLocalNotificationsPlugin.show
E/flutter (23943): <asynchronous suspension>
E/flutter (23943):
The solution is that I need to add the icon path when I set AndroidNotificationDetails.
static Future _notificationDetails() async {
return NotificationDetails(
android: AndroidNotificationDetails('channel id', 'channel name',
channelDescription: 'channel description',
importance: Importance.max,
==> icon: "#mipmap/ic_launcher"), <==
iOS: IOSNotificationDetails(),
);
}
just add icon parameter to AndroidNotificationDetails()

flutter firebase offline error caused by sending get request to real time database

im currently trying to use flutter and firebase realtime database together but i keep on getting this error whenever i try and get or update the database. it was working fine a few days ago but i accidently rolled back the changes.
i have done
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
name: "main_app",
options: FirebaseOptions(
apiKey: "XXXXXXXXXXXXXXXXXXXXXXXX",
authDomain: "fXXXXXXXXXXXXX",
databaseURL: "XXXXXXXXXXXXXXX",
projectId: "XXXXXXXXXXXXXXXXX",
storageBucket: "XXXXXXXXXXXXXX",
messagingSenderId: "XXXXXXXXXX",
appId: "XXXXXXXXXXXXXXXXXXXXX",
measurementId: "XXXXX"
)
);
the error occurs wheneever i do
FirebaseDatabase.instance.ref("/users").get()
i have tried different end points to check if that is the problem but the error is hard to understand imo
I/RepoOperation( 6096): get for query / falling back to disk cache after error: Client is offline
E/firebase_database( 6096): An unknown error occurred handling native method call Query#get
E/firebase_database( 6096): java.util.concurrent.ExecutionException: java.lang.Exception: Client is offline
E/firebase_database( 6096): at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-tasks##18.0.1:5)
E/firebase_database( 6096): at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-tasks##18.0.1:8)
E/firebase_database( 6096): at io.flutter.plugins.firebase.database.FirebaseDatabasePlugin.lambda$queryGet$8$FirebaseDatabasePlugin(FirebaseDatabasePlugin.java:248)
E/firebase_database( 6096): at io.flutter.plugins.firebase.database.-$$Lambda$FirebaseDatabasePlugin$zohedUhq4ZX8w6dhHgizPHWixGY.call(Unknown Source:4)
E/firebase_database( 6096): at com.google.android.gms.tasks.zzz.run(com.google.android.gms:play-services-tasks##18.0.1:1)
E/firebase_database( 6096): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/firebase_database( 6096): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/firebase_database( 6096): at java.lang.Thread.run(Thread.java:919)
E/firebase_database( 6096): Caused by: java.lang.Exception: Client is offline
E/firebase_database( 6096): at com.google.firebase.database.connection.PersistentConnectionImpl.lambda$get$1$PersistentConnectionImpl(PersistentConnectionImpl.java:441)
E/firebase_database( 6096): at com.google.firebase.database.connection.-$$Lambda$PersistentConnectionImpl$DHovbqW2nxPacSd_wNZBtpYapws.run(Unknown Source:8)
E/firebase_database( 6096): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
E/firebase_database( 6096): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/firebase_database( 6096): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
E/firebase_database( 6096): ... 3 more
E/flutter ( 6096): [ERROR:flutter/shell/common/shell.cc(94)] Dart Unhandled Exception: [firebase_database/unknown] java.lang.Exception: Client is offline
E/flutter ( 6096):
E/flutter ( 6096): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter ( 6096): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:367:43)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): #3 MethodChannelQuery.get (package:firebase_database_platform_interface/src/method_channel/method_channel_query.dart:74:22)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): #4 Query.get (package:firebase_database/src/query.dart:21:27)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): , stack trace: #0 MethodChannelQuery.get (package:firebase_database_platform_interface/src/method_channel/method_channel_query.dart:86:7)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096): #1 Query.get (package:firebase_database/src/query.dart:21:27)
E/flutter ( 6096): <asynchronous suspension>
E/flutter ( 6096):
You seem to be calling get(), while you're offline and with no data in the cache.
Keep in mind you have to explicitly enable disk persistence for the Firebase Realtime Database before it can read data from it while you're offline. You can do this by calling setPersistenceEnabled(true) at the start of the app, before calling any methods that read/write data:
FirebaseDatabase.instance.setPersistenceEnabled(true);
What I did and it worked for me. Just
flutter pub clean.
uninstall the app on your device.
flutter pub get

Agora exception in release mode Flutter

I am using Agora rtc in my flutter app for live streaming it works fine in debug mode
but in release I got this exception and live dose not start
log Exception when trying to open Live Stream :
E/flutter (22524): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, Incomplete hierarchy for class RtcEngineManager, unresolved classes [io.agora.rtc.base.IRtcEngine$RtcEngineInterface], null, java.lang.IllegalStateException: Incomplete hierarchy for class RtcEngineManager, unresolved classes [io.agora.rtc.base.IRtcEngine$RtcEngineInterface]
E/flutter (22524): at kotlin.reflect.jvm.internal.components.RuntimeErrorReporter.reportIncompleteHierarchy(Unknown Source:41)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassTypeConstructor.computeSupertypes(Unknown Source:211)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.types.AbstractTypeConstructor$supertypes$1.invoke(Unknown Source:4)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.types.AbstractTypeConstructor$supertypes$1.invoke(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(Unknown Source:86)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.types.AbstractTypeConstructor.getSupertypes(Unknown Source:2)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassMemberScope.getNonDeclaredVariableNames(Unknown Source:8)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedMemberScope$variableNamesLazy$2.invoke(Unknown Source:12)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedMemberScope$variableNamesLazy$2.invoke(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(Unknown Source:86)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.storage.StorageKt.getValue(Unknown Source:10)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedMemberScope.getVariableNamesLazy(Unknown Source:7)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedMemberScope.getVariableNames(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedMemberScope.addFunctionsAndProperties(Unknown Source:14)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedMemberScope.computeDescriptors(Unknown Source:36)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassMemberScope$allDescriptors$1.invoke(Unknown Source:12)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassMemberScope$allDescriptors$1.invoke(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(Unknown Source:86)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.storage.LockBasedStorageManager$LockBasedNotNullLazyValue.invoke(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassMemberScope.getContributedDescriptors(Unknown Source:12)
E/flutter (22524): at kotlin.reflect.jvm.internal.impl.resolve.scopes.ResolutionScope$DefaultImpls.getContributedDescriptors$default(Unknown Source:18)
E/flutter (22524): at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.getMembers(Unknown Source:17)
E/flutter (22524): at kotlin.reflect.jvm.internal.KClassImpl$Data$declaredNonStaticMembers$2.invoke(Unknown Source:10)
E/flutter (22524): at kotlin.reflect.jvm.internal.KClassImpl$Data$declaredNonStaticMembers$2.invoke(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(Unknown Source:17)
E/flutter (22524): at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(Unknown Source:0)
E/flutter (22524): at kotlin.reflect.jvm.internal.KClassImpl$Data.getDeclaredNonStaticMembers(Unknown Source:8)
E/flutter (22524): at kotlin.reflect.full.KClasses.getDe
E/flutter (22524): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, Please init RtcEngine first!,
null, java.lang.RuntimeException: Please init RtcEngine first!
E/flutter (22524): at io.agora.rtc.base.RtcSurfaceView.<init>(Unknown Source:36)

flutter crashing Attempt to invoke virtual method

I'm facing weird issue that make app crashing in production mode and it's happened once time and don't happened if I try same action I have did , so when try add item in firebase it's crashing and if return try same item in same condition maybe didn't crashed but I have cashed these issues
the first issue
/AndroidRuntime( 9758): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
E/AndroidRuntime( 9758): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:451)
E/AndroidRuntime( 9758): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$EventObserver.onEvent(CloudFirestorePlugin.java:433)
E/AndroidRuntime( 9758): at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore##21.3.0:1025)
E/AndroidRuntime( 9758): at com.google.firebase.firestore.Query$$Lambda$3.onEvent(Unknown Source:6)
E/AndroidRuntime( 9758): at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore##21.3.0:42)
E/AndroidRuntime( 9758): at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(Unknown Source:6)
E/AndroidRuntime( 9758): at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime( 9758): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 9758): at com.google.android.gms.internal.tasks.zzb.dispatchMessage(com.google.android.gms:play-services-tasks##17.0.2:6)
E/AndroidRuntime( 9758): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 9758): at android.app.ActivityThread.main(ActivityThread.java:7156)
E/AndroidRuntime( 9758): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9758): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/AndroidRuntime( 9758): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
I/System.out( 9758): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out( 9758): (HTTPLog)-Static: isSBSettingEnabled false
D/NetworkManagementSocketTagger( 9758): tagSocket(93) with statsTag=0xffffffff, statsUid=-1
D/NetworkManagementSocketTagger( 9758): tagSocket(65) with statsTag=0xffffffff, statsUid=-1
the second issue
Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'void j.b.a.a.n.a(java.lang.String, java.lang.Object)' on a null object reference
io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$DocumentObserver.a (CloudFirestorePlugin.java:106)
io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$DocumentObserver.a (CloudFirestorePlugin.java:2)
com.google.firebase.firestore.DocumentReference.a (DocumentReference.java:87)
com.google.firebase.firestore.DocumentReference$$Lambda$3.a (DocumentReference.java:6)
com.google.firebase.firestore.core.AsyncEventListener.a (AsyncEventListener.java:6)
com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run (AsyncEventListener.java:6)
android.os.Handler.handleCallback (Handler.java:873)
android.os.Handler.dispatchMessage (Handler.java:99)
com.google.android.gms.internal.tasks.zzb.dispatchMessage (zzb.java)
android.os.Looper.loop (Looper.java:214)
android.app.ActivityThread.main (ActivityThread.java:7156)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)
another issue
E/flutter (24582): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.AssertionError: java.lang.NoSuchFieldException: DrawableResource
E/flutter (24582): at c.c.e.y.n.n$k0.<init>(Unknown Source:87)
E/flutter (24582): at c.c.e.y.n.n$w.a(Unknown Source:29)
E/flutter (24582): at c.c.e.f.a(Unknown Source:74)
E/flutter (24582): at c.c.e.y.n.i.a(Unknown Source:42)
E/flutter (24582): at c.c.e.y.n.i.a(Unknown Source:123)
E/flutter (24582): at c.c.e.y.n.i.a(Unknown Source:22)
E/flutter (24582): at c.c.e.f.a(Unknown Source:74)
E/flutter (24582): at c.c.e.f.a(Unknown Source:4)
E/flutter (24582): at c.c.e.f.a(Unknown Source:8)
E/flutter (24582): at c.c.e.f.a(Unknown Source:5)
E/flutter (24582): at c.c.e.f.a(Unknown Source:13)
E/flutter (24582): at com.dexterous.flutterlocalnotifications.b.b(Unknown Source:4)
E/flutter (24582): at com.dexterous.flutterlocalnotifications.b.f(Unknown Source:19)
E/flutter (24582): at com.dexterous.flutterlocalnotifications.b.onMethodCall(Unknown Source:169)
E/flutter (24582): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(Unknown Source:17)
E/flutter (24582): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(Unknown Source:57)
E/flutter (24582): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
E/flutter (24582): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (24582): at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter (24582): at android.os.Looper.loop(Looper.java:181)
E/flutter (24582): at android.app.ActivityThread.main(ActivityThread.java:7156)
E/flutter (24582): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (24582): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/flutter (24582): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
E/flutter (24582): Caused by: java.lang.NoSuchFieldException: DrawableResource
E/flutter (24582): at java.lang.Class.getField(Class.java:1601)
E/flutter (24582): at c.c.e.y.n.n$k0.<init>(Unknown Source:34)
E/flutter (24582): ... 23 more
E/flutter (24582):
F/flutter (24582): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(76)] Check failed: CheckException(env).
This issue doesn't seem to happen on cloud_firestore: ^3.1.7. Try updating the cloud_firestore version that you're using. If that doesn't work, see if proguard is enabled on your Android build. Updating android.enableR8=false the Android build's gradle.properties also works to some.

Flutter app crashing on android 10 & R with No static method isAtLeastR

I've seen a few issues similar on Stack overflow, but not one that quite relates to the same libraries.
I'm trying to use 2 plugins in flutter
flutter_geofence and geolocator
They've both been working fine, but since yesterday as soon as of the location play services are called I'm getting the app quit with a stack trace similar to below:
E/flutter (11478): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.NoSuchMethodError: No static method isAtLeastR()Z in class Landroidx/core/os/BuildCompat; or its super classes (declaration of 'androidx.core.os.BuildCompat' appears in /data/app/com.mypossibleself.app-FTu9V5QDAKR_ngQmuPzg7Q==/base.apk!classes2.dex)
E/flutter (11478): at com.google.android.gms.common.util.PlatformVersion.isAtLeastR(com.google.android.gms:play-services-basement##17.2.1:21)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.zaa(com.google.android.gms:play-services-base##17.2.1:128)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.<init>(com.google.android.gms:play-services-base##17.2.1:41)
E/flutter (11478): at com.google.android.gms.common.api.GoogleApi.<init>(com.google.android.gms:play-services-base##17.2.1:56)
E/flutter (11478): at com.google.android.gms.location.FusedLocationProviderClient.<init>(Unknown Source:8)
E/flutter (11478): at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source:2)
E/flutter (11478): at com.baseflow.geolocator.tasks.LocationUpdatesUsingLocationServicesTask.<init>(LocationUpdatesUsingLocationServicesTask.java:29)
E/flutter (11478): at com.baseflow.geolocator.tasks.TaskFactory.createStreamLocationUpdatesTask(TaskFactory.java:120)
E/flutter (11478): at com.baseflow.geolocator.GeolocatorPlugin.onListen(GeolocatorPlugin.java:110)
E/flutter (11478): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:193)
E/flutter (11478): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:172)
E/flutter (11478): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/flutter (11478): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/flutter (11478): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (11478): at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter (11478): at android.os.Looper.loop(Looper.java:174)
E/flutter (11478): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/flutter (11478): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (11478): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/flutter (11478): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
So it's complaining about a missing method isAtLeastR
Other references I've seen to this mention specific versions of com.google.android.gms:play-services-base causing this, but that it's fixed in com.google.android.gms:play-services-base:17.2.1
Neither of these library implement that package in their build.gradle files so I'm at a loss as to what needs doing to fix this issue.
In the app/build.gradle add com.google.android.gms:play-services-base:17.2.1 this should make libraries use specific version of play-services.
If it doesn't help, might need to
configurations.all {
resolutionStrategy {
force 'com.google.needed_dependency'
}
}
https://flutter.dev/docs/development/packages-and-plugins/using-packages#conflict-resolution
Edit as per Andrews suggestion:
17.2.1 doesn't work, but 17.0.0 does.
implementation("com.google.android.gms:play-services-base:17.0.0"){ force = true }
resolutionStrategy {
force 'com.google.android.gms:play-services-base:17.1.0'
}
}
This is what solved it for me.

Categories

Resources