background_locator_fixed icon indicating copy to clipboard operation
background_locator_fixed copied to clipboard

Android app crashing while on location service. in share build via google drive link and diawi link

Open vishalm29 opened this issue 2 years ago • 3 comments

java.lang.RuntimeException: Unable to start service yukams.app.background_locator_2.IsolateHolderService@c2a45c6 with Intent { act=UPDATE_NOTIFICATION cmp=com.techguy/yukams.app.background_locator_2.IsolateHolderService (has extras) }: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=app.yukams/locator_plugin pri=1 contentView=null vibrate=null sound=null defaults=0x0 flags=0xa color=0x00000000 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)

Caused by: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=app.yukams/locator_plugin pri=1 contentView=null vibrate=null sound=null defaults=0x0 flags=0xa color=0x00000000 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)

vishalm29 avatar Aug 18 '22 07:08 vishalm29

Hello buddy i am using this version. 2.0.6-dev.1 And the android app crash in release build while stating the location service

runBackGrounLocation() async { AppUtils.showToast("11111111"); FirebaseCrashlytics.instance.recordError("runbackground",StackTrace.empty); var rrr1 = await AppUtils.checkLocationBackGroundPermission(); if(!rrr1){ return; } try{ port = ReceivePort(); if (IsolateNameServer.lookupPortByName( fetchBackgroundLocation) != null) { IsolateNameServer.removePortNameMapping( fetchBackgroundLocation); } IsolateNameServer.registerPortWithName(port.sendPort, fetchBackgroundLocation); //port.listen((dynamic data) async {},); AppUtils.showToast("222222222"); FirebaseCrashlytics.instance.recordError("22222222222",StackTrace.empty); await BackgroundLocator.initialize(); _startLocator(); }catch(e){ AppUtils.showToast(e.toString()); }

}

Future _startLocator() async { AppUtils.showToast("333333333"); FirebaseCrashlytics.instance.recordError("3333333333",StackTrace.empty); try{ Map<String, dynamic> data = {'countInit': 1}; return await BackgroundLocator.registerLocationUpdate(callback, initCallback: LocationCallbackHandler.initCallback, disposeCallback: LocationCallbackHandler.disposeCallback, autoStop: false, iosSettings: IOSSettings( accuracy: LocationAccuracy.NAVIGATION, distanceFilter: 10, stopWithTerminate: true ), androidSettings: AndroidSettings( accuracy: LocationAccuracy.NAVIGATION, interval: 5, distanceFilter: 10, client: LocationClient.google, androidNotificationSettings: AndroidNotificationSettings( notificationChannelName: 'Location tracking', notificationTitle: 'Start Location Tracking', notificationMsg: 'Track location in background', notificationBigMsg: 'Background location is on to keep the app up-tp-date with your location. This is required for main features to work properly when the app is not running.', notificationIconColor: Colors.white, notificationTapCallback: LocationCallbackHandler.notificationCallback)) );

}catch(e){
  AppUtils.showToast(e.toString());
  FirebaseCrashlytics.instance.recordError(e.toString(),StackTrace.empty);
}

}

static Future callback(LocationDto locationDto) async { FirebaseCrashlytics.instance.recordError("66666666666666",StackTrace.empty); try{ final SendPort? send = IsolateNameServer.lookupPortByName(fetchBackgroundLocation); Future.delayed(Duration(seconds: 1),(){ _updateNotificationText(locationDto); }); FirebaseCrashlytics.instance.recordError("77777777777777",StackTrace.empty); if(locationDto != null){ FirebaseCrashlytics.instance.recordError("999999999999",StackTrace.empty); Map<String,dynamic> map = {"lat":locationDto.latitude,"long":locationDto.longitude}; FirebaseCrashlytics.instance.recordError("yyyyyyyyyyy",StackTrace.empty); AppUtils.showToast(map.toString()); sendLocation(map); } send?.send(locationDto); FirebaseCrashlytics.instance.recordError("ppppppppppp",StackTrace.empty); }catch(e){ AppUtils.showToast(e.toString()); }

}

class LocationCallbackHandler { static Future initCallback(Map<dynamic, dynamic> params) async { FirebaseCrashlytics.instance.recordError("55555555",StackTrace.empty); AppUtils.showToast("555555"); final SendPort? send = IsolateNameServer.lookupPortByName(fetchBackgroundLocation); send?.send(null); }

static Future disposeCallback() async { FirebaseCrashlytics.instance.recordError("dispose calback",StackTrace.empty); AppUtils.showToast("dispose calback"); final SendPort? send = IsolateNameServer.lookupPortByName(fetchBackgroundLocation); send?.send(null); }

static Future notificationCallback() async { FirebaseCrashlytics.instance.recordError("0000000000",StackTrace.empty); AppUtils.showToast("0000000000"); print('***notificationCallback');

} }

vishalm29 avatar Aug 19 '22 07:08 vishalm29

The same error with notification

Strafe0 avatar Feb 14 '23 07:02 Strafe0

I have fixed this by setting the notification icon:

notificationIcon: 'launcher_icon',

It is located in the "mipmap" directories in the Android folder


  androidSettings: const AndroidSettings(
    accuracy: LocationAccuracy.NAVIGATION,
    interval: 5,
    distanceFilter: 0,
    client: LocationClient.google,
    androidNotificationSettings: AndroidNotificationSettings(
      notificationChannelName: 'Location tracking',
      notificationTitle: 'Start Location Tracking',
      notificationMsg: 'Track location in background',
      notificationBigMsg:
          'Background location is on to keep the app up-tp-date with your location. This is required for main features to work properly when the app is not running.',
      // notificationIcon: 'ic_stat_ac_unit',
      notificationIcon: 'launcher_icon',
      notificationIconColor: Colors.grey,
      notificationTapCallback: LocationCallbackHandler.notificationCallback,
    ),
  ),

ibelz avatar May 09 '23 16:05 ibelz