Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] my app stops working after kill the app #127

Closed
is10vmust opened this issue Jun 14, 2020 · 19 comments
Closed

[BUG] my app stops working after kill the app #127

is10vmust opened this issue Jun 14, 2020 · 19 comments
Labels

Comments

@is10vmust
Copy link

is10vmust commented Jun 14, 2020

Your Environment

  • Plugin version: ^1.7.0
  • Platform: Android
  • OS version: Android 8-10
  • Device manufacturer / model: samsung g7 and pixel 3 xl (emulator)
  • Flutter info (flutter info, flutter doctor): fine no problems
  • Plugin config

MY LOGCAT

2020-06-14 18:44:33.083 1919-1919/com.google.android.gms.persistent E/BeaconBle: Scan couldn't start for Places
2020-06-14 18:44:33.084 1919-1919/com.google.android.gms.persistent W/Places: BLE failure while scanning - code 5
2020-06-14 18:44:33.087 1919-13806/com.google.android.gms.persistent I/Places: ?: Couldn't find platform key file.
2020-06-14 18:44:33.104 2934-13481/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.106 2934-13481/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.107 2934-13478/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.107 2934-13481/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.109 2934-13481/com.google.android.googlequicksearchbox:search I/chatty: uid=10030(u0_a30) NonUserFacing17 identical 1 line
2020-06-14 18:44:33.109 2934-13481/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.111 2934-13478/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.114 2934-13481/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.114 2934-13478/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.116 2934-13478/com.google.android.googlequicksearchbox:search I/chatty: uid=10030(u0_a30) NonUserFacing17 identical 1 line
2020-06-14 18:44:33.117 2934-13478/com.google.android.googlequicksearchbox:search E/PlaceStateUpdater: Received no places
2020-06-14 18:44:33.348 13112-13159/com.google.android.apps.nexuslauncher W/OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
2020-06-14 18:44:34.451 13318-13318/com.ensperity.projectcoronas D/TSBackgroundFetch: - Background Fetch event received
2020-06-14 18:44:34.453 13318-13318/com.ensperity.projectcoronas D/TSBackgroundFetch: 💀 [HeadlessTask com.transistorsoft.customtask]
2020-06-14 18:44:34.467 13318-13318/com.ensperity.projectcoronas D/EGL_emulation: eglCreateContext: 0xa2a8efe0: maj 3 min 1 rcv 4
2020-06-14 18:44:34.499 13318-13968/com.ensperity.projectcoronas D/EGL_emulation: eglMakeCurrent: 0xa2a8efe0: ver 3 1 (tinfo 0xa2d83d60)
2020-06-14 18:44:34.504 13318-13968/com.ensperity.projectcoronas E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
2020-06-14 18:44:34.504 13318-13968/com.ensperity.projectcoronas E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
2020-06-14 18:44:34.573 13318-13318/com.ensperity.projectcoronas D/BeaconParser: Parsing beacon layout: m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24
2020-06-14 18:44:34.577 13318-13318/com.ensperity.projectcoronas W/FlutterEnginePluginRegistry: Attempted to register plugin (io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry$ShimRegistrarAggregate@fb16e92) but it was already registered with this FlutterEngine (io.flutter.embedding.engine.FlutterEngine@528c063).
2020-06-14 18:44:34.577 13318-13318/com.ensperity.projectcoronas E/MethodChannel#: Parameter messenger must not be null.
2020-06-14 18:44:34.577 13318-13318/com.ensperity.projectcoronas E/MethodChannel#: Parameter messenger must not be null.
2020-06-14 18:44:34.577 13318-13318/com.ensperity.projectcoronas D/AndroidRuntime: Shutting down VM
2020-06-14 18:44:34.578 13318-13318/com.ensperity.projectcoronas E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ensperity.projectcoronas, PID: 13318
    java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.BinaryMessenger.setMessageHandler(java.lang.String, io.flutter.plugin.common.BinaryMessenger$BinaryMessageHandler)' on a null object reference
        at io.flutter.plugin.common.MethodChannel.setMethodCallHandler(MethodChannel.java:116)
        at io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.onAttachedToEngine(FirebaseMessagingPlugin.java:62)
        at io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(FirebaseMessagingPlugin.java:52)
        at com.ensperity.projectcoronas.FirebaseCloudMessagingPluginRegistrant$Companion.registerWith(FirebaseCloudMessagingPluginRegistrant.kt:12)
        at com.ensperity.projectcoronas.Application.registerWith(Application.kt:20)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.startBackgroundIsolate(HeadlessTask.java:150)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.dispatch(HeadlessTask.java:101)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.run(HeadlessTask.java:95)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
2020-06-14 18:44:34.580 13318-13318/com.ensperity.projectcoronas E/TSLocationManager: [c.t.l.a.BackgroundGeolocation$e uncaughtException] 
      ‼️  Uncaught Exception: Attempt to invoke interface method 'void io.flutter.plugin.common.BinaryMessenger.setMessageHandler(java.lang.String, io.flutter.plugin.common.BinaryMessenger$BinaryMessageHandler)' on a null object reference
    {"activityRecognitionInterval":10000,"allowIdenticalLocations":false,"authorization":{},"autoSync":true,"autoSyncThreshold":0,"batchSync":false,"configUrl":"","debug":false,"deferTime":0,"desiredAccuracy":-1,"desiredOdometerAccuracy":100,"disableAutoSyncOnCellular":false,"disableElasticity":false,"disableLocationAuthorizationAlert":false,"disableMotionActivityUpdates":false,"disableStopDetection":false,"distanceFilter":10,"elasticityMultiplier":1,"enableHeadless":true,"enableTimestampMeta":false,"encrypt":false,"extras":{},"fastestLocationUpdateInterval":-1,"forceReloadOnBoot":false,"forceReloadOnGeofence":false,"forceReloadOnHeartbeat":false,"forceReloadOnLocationChange":false,"forceReloadOnMotionChange":false,"forceReloadOnSchedule":false,"foregroundService":true,"geofenceInitialTriggerEntry":true,"geofenceModeHighAccuracy":false,"geofenceProximityRadius":1000,"geofenceTemplate":"","headers":{},"headlessJobService":"com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask","heartbeatInterval":60,"httpRootProperty":"location","httpTimeout":60000,"isMoving":false,"locationAuthorizationRequest":"Always","locationTemplate":"","locationTimeout":60,"locationUpdateInterval":1000,"locationsOrderDirection":"ASC","logLevel":5,"logMaxDays":3,"maxBatchSize":-1,"maxDaysToPersist":1,"maxRecordsToPersist":-1,"method":"POST","minimumActivityRecognitionConfidence":75,"notification":{"layout":"","title":"","text":"Location Service activated","color":"","channelName":"TSLocationManager","smallIcon":"","largeIcon":"","priority":0,"strings":{},"actions":[]},"params":{},"persist":true,"persistMode":2,"schedule":[],"scheduleUseAlarmManager":false,"speedJumpFilter":300,"startOnBoot":true,"stationaryRadius":25,"stopAfterElapsedMinutes":0,"stopOnStationary":false,"stopOnTerminate":false,"stopTimeout":1,"triggerActivities":"on_foot, walking, running, in_vehicle, on_bicycle","url":"","useSignificantChangesOnly":false,"enabled":true,"schedulerEnabled":false,"trackingMode":1,"odometer":0,"isFirstBoot":false,"didLaunchInBackground":false}
    java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.BinaryMessenger.setMessageHandler(java.lang.String, io.flutter.plugin.common.BinaryMessenger$BinaryMessageHandler)' on a null object reference
        at io.flutter.plugin.common.MethodChannel.setMethodCallHandler(MethodChannel.java:116)
        at io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.onAttachedToEngine(FirebaseMessagingPlugin.java:62)
        at io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(FirebaseMessagingPlugin.java:52)
        at com.ensperity.projectcoronas.FirebaseCloudMessagingPluginRegistrant$Companion.registerWith(FirebaseCloudMessagingPluginRegistrant.kt:12)
        at com.ensperity.projectcoronas.Application.registerWith(Application.kt:20)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.startBackgroundIsolate(HeadlessTask.java:150)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.dispatch(HeadlessTask.java:101)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.run(HeadlessTask.java:95)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

My Config

allowIdenticalLocations: false,
triggerActivities: 'on_foot, walking, running, in_vehicle, on_bicycle',
desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
reset: true,
debug: false,
logLevel: bg.Config.LOG_LEVEL_VERBOSE,
distanceFilter: 50.0, //aman-50
stopTimeout: 1,
autoSync: true,
stopOnTerminate: false,
foregroundService: true,
startOnBoot: true,
disableMotionActivityUpdates: true,
enableHeadless: true,

My Headless
in foreground everything is ok but when i kill the app the headless run the code faster x10
this is my headless method:

void backgroundGeolocationHeadlessTask(bg.HeadlessEvent headlessEvent) async {
print("LOCATION PLUG-IN in BACKGROUND...");

PreferenceUtils.init();
kill();
bleStatus();
checkInternet();
gps();
// checkInterNetLive();
BLE().scan();
DatabaseHelper helper = new DatabaseHelper();
helper.initializeDatabase();
getUserLocation(helper);
}

Debug logs
W/FlutterEnginePluginRegistry(11730): Attempted to register plugin (io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry$ShimRegistrarAggregate@90a06e1) but it was already registered with this FlutterEngine (io.flutter.embedding.engine.FlutterEngine@a63ac06).

Additional context
this happened after i set the switch event on my headless, then everything works fine and good but every time i killed the app the app crashed and stopped working ,
Many thanks

@christocracy
Copy link
Member

Your issue comes from io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.onAttachedToEngine(FirebaseMessagingPlugin.java:62)

@christocracy
Copy link
Member

Provide the following files:

  • com.ensperity.projectcoronas.Application.kt
  • AndroidManifest.xml

@is10vmust
Copy link
Author

is10vmust commented Jun 14, 2020

My Application.kt

package com.ensperity.projectcoronas

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
import com.transistorsoft.flutter.backgroundgeolocation.FLTBackgroundGeolocationPlugin;
import com.transistorsoft.flutter.backgroundfetch.BackgroundFetchPlugin;

public class Application: FlutterApplication(), PluginRegistrantCallback {
  override fun onCreate() {
    super.onCreate()
    BackgroundFetchPlugin.setPluginRegistrant(this)
    FlutterFirebaseMessagingService.setPluginRegistrant(this)
  
  }

  override fun registerWith(registry: PluginRegistry) {
    FLTBackgroundGeolocationPlugin.setPluginRegistrant(this)
    FirebaseCloudMessagingPluginRegistrant.registerWith(registry)
    
  }
}

@christocracy
Copy link
Member

Please learn to use Github syntax highlighting.

@christocracy
Copy link
Member

I asked for 2 files, including AndroidManifest.xml

@transistorsoft transistorsoft deleted a comment from is10vmust Jun 14, 2020
@is10vmust
Copy link
Author

is10vmust commented Jun 14, 2020

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.ensperity.projectcoronas">
	<!--
	io.flutter.app.FlutterApplication is an android.app.Application that
	calls FlutterMain.startInitialization(this); in its onCreate method.
	In most cases you can leave this as-is, but you if you want to provide
	additional functionality it is fine to subclass or reimplement
	FlutterApplication and put your custom class here.
	-->
	<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
	<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
	<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.CAMERA" />
	<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
	<uses-permission android:name="android.permission.WAKE_LOCK" />
	<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
	<application tools:replace="android:label" android:name=".Application" android:label="Myapp" android:usesCleartextTraffic="true" android:icon="@mipmap/ic_launcher">
		<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
			<intent-filter>
				<action android:name="FLUTTER_NOTIFICATION_CLICK" />
				<category android:name="android.intent.category.DEFAULT" />
			</intent-filter>
			<meta-data android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" android:value="true" />
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
		<meta-data android:name="com.transistorsoft.locationmanager.license" android:value="Redacted" />
		<meta-data android:name="com.transistorsoft.locationmanager.ENCRYPTION_PASSWORD" android:value="" />
		<meta-data android:name="flutterEmbedding" android:value="2" />
	</application>
</manifest>

@christocracy
Copy link
Member

This line shows your app has been upgraded to flutter sdk >= 1.12. You no longer need a custom Application.kt.

<meta-data android:name="flutterEmbedding" android:value="2" />

See the Android Setup

Modify your AndroidManifest.xml

<application
+        android:name="io.flutter.app.FlutterApplication"

@is10vmust
Copy link
Author

This line shows your app has been upgraded to flutter sdk >= 1.12. You no longer need a custom Application.kt.

<meta-data android:name="flutterEmbedding" android:value="2" />

See the Android Setup

Modify your AndroidManifest.xml

<application
+        android:name="io.flutter.app.FlutterApplication"

i applied this changes and after that the background not worked at all

@christocracy
Copy link
Member

Then you must figure out that problem.

Do NOT use a custom Application.kt with Flutter sdk >= 1.12

@dimple3695
Copy link

dimple3695 commented Jul 3, 2020

This line shows your app has been upgraded to flutter sdk >= 1.12. You no longer need a custom Application.kt.

<meta-data android:name="flutterEmbedding" android:value="2" />

See the Android Setup
Modify your AndroidManifest.xml

<application
+        android:name="io.flutter.app.FlutterApplication"

i applied this changes and after that the background not worked at all

I also same issue? If your problem resolved Please Can you suggest me how to solve it?

@uzirthapa
Copy link

I Ran the example application for iOS and when I kill the application, and try to open it again, the app crashes on startup. Any fixes for this?

Also, please let me know if you need more details.

My version is iOS 14.0 and using on IPhone XR

@christocracy
Copy link
Member

If the app crashes, provided the stacktrace here.

@uzirthapa
Copy link

uzirthapa commented Jul 9, 2020

When launching through XCode it is okay, this only happens once you kill the app and then try to reopen it.

Here are the logs from the device for the example app

Incident Identifier: 61E75D87-D8DE-4A34-B2D6-86465315A518
CrashReporter Key: bd243a2ec0e9193d3e47b9dcc99ec8e558b91db9
Hardware Model: iPhone11,8
Process: Runner [18851]
Path: /private/var/containers/Bundle/Application/BC0F6237-72AD-4FE9-97F1-BAF5A66EEDF4/Runner.app/Runner
Identifier: com.transistorsoft.flutter.backgroundfetch.backgroundFetchExample
Version: 1 (1.0.0)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.transistorsoft.flutter.backgroundfetch.backgroundFetchExample [2048]

Date/Time: 2020-07-09 07:38:48.2077 -0500
Launch Time: 2020-07-09 07:38:47.9566 -0500
OS Version: iPhone OS 14.0 (18A5301v)
Release Type: Beta
Baseband Version: 2.50.07
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGKILL - CODESIGNING)
Exception Subtype: UNKNOWN_0x32 at 0x000000010ae81d60
VM Region Info: 0x10ae81d60 is in 0x10ae80000-0x10af00000; bytes after start: 7520 bytes before end: 516767
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
VM_ALLOCATE 10ae00000-10ae80000 [ 512K] r--/rwx SM=PRV
---> VM_ALLOCATE 10ae80000-10af00000 [ 512K] r-x/rwx SM=COW
MALLOC_LARGE 10af00000-10af10000 [ 64K] rw-/rwx SM=PRV

Termination Reason: Namespace CODESIGNING, Code 0x2
Triggered by Thread: 7

@christocracy
Copy link
Member

Termination Reason: Namespace CODESIGNING

Open your app in XCode and configure your code-signing as required.

@christocracy
Copy link
Member

Also see this that I found while googling "Termination Reason: Namespace CODESIGNING".

@uzirthapa
Copy link

I do have XCode Automatically Signing for me as well. I am trying the release build to see if that works.

Screen Shot 2020-07-09 at 7 58 35 AM

@uzirthapa
Copy link

The release build works! But its interesting that if I close the app in debug mode, it crashes on restart. Will see if we can find a better solution for that. Otherwise I will work with the release build for now.

Thank you!

@stale
Copy link

stale bot commented Mar 19, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

@stale stale bot added the stale label Mar 19, 2021
@stale
Copy link

stale bot commented Jun 16, 2021

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

@stale stale bot closed this as completed Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants