urbanairship / airship-flutter

Flutter integration
Other
17 stars 18 forks source link

Android device debug issue #180

Closed hemantchauhan closed 5 months ago

hemantchauhan commented 1 year ago

What Airship dependencies are you using?

airship_flutter: ^7.0.0

What are the versions of any relevant development tools you are using?

VSCode 1.82, Dart v3.72.2

What unexpected behavior are you seeing?

I am unable to run my flutter app on device(Samsung Galaxy A03 core) after installing flutter airship

What are the steps to reproduce the unexpected behavior?

add dependency in pub spec.yaml file and click Run - Start debugging

Do you have logging for the issue?

Launching lib/main.dart on SM A032F in debug mode... main.dart:1 Building with Flutter multidex support enabled. ✓ Built build/app/outputs/flutter-apk/app-debug.apk. E/AndroidRuntime(5085): FATAL EXCEPTION: main E/AndroidRuntime(5085): Process: com.myjourney, PID: 5085 E/AndroidRuntime(5085): java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: androidx.startup.StartupException: java.lang.IllegalStateException: WorkManager is already initialized. Did you try to initialize it manually without disabling WorkManagerInitializer? See WorkManager#initialize(Context, Configuration) or the class level Javadoc for more information. E/AndroidRuntime(15085): at android.app.ActivityThread.installProvider(ActivityThread.java:7540)

rlepinski commented 1 year ago

My guess is some other plugin is improperly initializing work manager, or is not updated to the new way of using work manager. Could you list your dependencies? Both ./gradlew app:dependencies and the plugins you have installed? Do you initialize work manager in the app directly?

hemantchauhan commented 1 year ago

from a stackoverflow answer, I put the following in my AndroidManifest.xml file - <provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" android:exported="false" android:enabled="false" tools:node="merge"> <meta-data android:name="androidx.work.WorkManagerInitializer" android:value="androidx.startup" android:enabled="false" android:exported="false"/> </provider> the app is running now on device, but I have not received test push from go.airship.com test app I am getting the following logs

Launching lib/main.dart on SM A032F in debug mode... Building with Flutter multidex support enabled. ✓ Built build/app/outputs/flutter-apk/app-debug.apk. Connecting to VM Service at ws://127.0.0.1:58521/hCHGNvU=/ws V/UALib-Framework( 1821): Failed to load config from properties file: Unable to apply config from file airshipconfig.properties I/My Journey - UALib( 1821): Airship taking off! I/My Journey - UALib( 1821): Airship log level: 3 I/My Journey - UALib( 1821): UA Version: 17.1.0 / App key = AZkL6Iu2RiS9ofahegBQ0w Production = false E/My Journey - UALib( 1821): The Airship config options is missing URL allow list rules for SCOPE_OPEN that controls what external URLs are able to be opened externally or loaded in a web view by Airship. By default, all URLs will be allowed. To suppress this error, specify the config urlAllowListScopeOpenUrl = [*] to keep the defaults, or by providing a list of rules that your app expects. See https://docs.airship.com/platform/mobile/setup/sdk/android/#url-allow-list for more information. E/My Journey - UALib( 1821): Scheduler failed to schedule jobInfo E/My Journey - UALib( 1821): com.urbanairship.job.SchedulerException: Failed to schedule job E/My Journey - UALib( 1821): at com.urbanairship.job.WorkManagerScheduler.schedule(WorkManagerScheduler.java:31) E/My Journey - UALib( 1821): at com.urbanairship.job.JobDispatcher.dispatch(JobDispatcher.java:122) E/My Journey - UALib( 1821): at com.urbanairship.job.JobDispatcher.dispatch(JobDispatcher.java:116) E/My Journey - UALib( 1821): at com.urbanairship.remotedata.RemoteDataRefreshManager.dispatchRefreshJob(RemoteDataRefreshManager.kt:75) E/My Journey - UALib( 1821): at com.urbanairship.remotedata.RemoteData.(RemoteData.kt:149) E/My Journey - UALib( 1821): at com.urbanairship.remotedata.RemoteData.(RemoteData.kt:55) E/My Journey - UALib( 1821): at com.urbanairship.remotedata.RemoteData.(RemoteData.kt:95) E/My Journey - UALib( 1821): at com.urbanairship.UAirship.init(UAirship.java:755) E/My Journey - UALib( 1821): at com.urbanairship.UAirship.executeTakeOff(UAirship.java:427) E/My Journey - UALib( 1821): at com.urbanairship.UAirship.access$000(UAirship.java:72) E/My Journey - UALib( 1821): at com.urbanairship.UAirship$2.run(UAirship.java:386) E/My Journey - UALib( 1821): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/My Journey - UALib( 1821): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/My Journey - UALib( 1821): at com.urbanairship.util.AirshipThreadFactory$1.run(AirshipThreadFactory.java:50) E/My Journey - UALib( 1821): at java.lang.Thread.run(Thread.java:920) E/My Journey - UALib( 1821): Caused by: java.lang.IllegalStateException: WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider. E/My Journey - UALib( 1821): at androidx.work.impl.WorkManagerImpl.getInstance(WorkManagerImpl.java:158) E/My Journey - UALib( 1821): at androidx.work.WorkManager.getInstance(WorkManager.java:184) E/My Journey - UALib( 1821): at com.urbanairship.job.WorkManagerScheduler.schedule(WorkManagerScheduler.java:28) E/My Journey - UALib( 1821): ... 14 more D/My Journey - UALib( 1821): PermissionsManager - Checking permission for display_notifications D/My Journey - UALib( 1821): PermissionsManager - Check permission display_notifications status result: granted E/My Journey - UALib( 1821): Scheduler failed to schedule jobInfo E/My Journey - UALib( 1821): com.urbanairship.job.SchedulerException: Failed to schedule job E/My Journey - UALib( 1821): at com.urbanairship.job.WorkManagerScheduler.schedule(WorkManagerScheduler.java:31) E/My Journey - UALib( 1821): at com.urbanairship.job.JobDispatcher.dispatchPending(JobDispatcher.java:141) E/My Journey - UALib( 1821): at com.urbanairship.job.JobDispatcher.dispatch(JobDispatcher.java:121) E/My Journey - UALib( 1821): at com.urbanairship.job.JobDispatcher.dispatch(JobDispatcher.java:116) E/My Journey - UALib( 1821): at com.urbanairship.push.PushManager.dispatchUpdateJob(PushManager.java:451) E/My Journey - UALib( 1821): at com.urbanairship.push.PushManager.updateManagerEnablement(PushManager.java:430) E/My Journey - UALib( 1821): at com.urbanairship.push.PushManager.init(PushManager.java:352) E/My Journey - UALib( 1821): at com.urbanairship.UAirship.init(UAirship.java:823) E/My Journey - UALib( 1821): at com.urbanairship.UAirship.executeTakeOff(UAirship.java:427) E/My Journey - UALib( 1821): at com.urbanairship.UAirship.access$000(UAirship.java:72) E/My Journey - UALib( 1821): at com.urbanairship.UAirship$2.run(UAirship.java:386) E/My Journey - UALib( 1821): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/My Journey - UALib( 1821): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/My Journey - UALib( 1821): at com.urbanairship.util.AirshipThreadFactory$1.run(AirshipThreadFactory.java:50) E/My Journey - UALib( 1821): at java.lang.Thread.run(Thread.java:920) E/My Journey - UALib( 1821): Caused by: java.lang.IllegalStateException: WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider. E/My Journey - UALib( 1821): at androidx.work.impl.WorkManagerImpl.getInstance(WorkManagerImpl.java:158) E/My Journey - UALib( 1821): at androidx.work.WorkManager.getInstance(WorkManager.java:184) E/My Journey - UALib( 1821): at com.urbanairship.job.WorkManagerScheduler.schedule(WorkManagerScheduler.java:28) E/My Journey - UALib( 1821): ... 14 more I/My Journey - UALib( 1821): Airship ready! D/My Journey - UALib( 1821): Autopilot - Airship ready! I/FlutterAutopilot( 1821): onAirshipReady D/My Journey - UALib( 1821): PermissionsManager - Checking permission for display_notifications D/ConnectivityManager( 1821): StackLog: [android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:3925)] [android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4489)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4456)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4430)] [com.urbanairship.automation.NetworkMonitor.registerNetworkCallback(NetworkMonitor.java:51)] [com.urbanairship.automation.NetworkMonitor.setConnectionListener(NetworkMonitor.java:78)] [com.urbanairship.automation.AutomationEngine.start(AutomationEngine.java:284)] [com.urbanairship.automation.InAppAutomation.ensureStarted(InAppAutomation.java:881)] [com.urbanairship.automation.InAppAutomation.checkUpdatesSubscription(InAppAutomation.java:888)] [com.urbanairship.automation.InAppAutomation.onAirshipReady(InAppAutomation.java:300)] [com.urbanairship.UAirship.executeTakeOff(UAirship.java:438)] [com.urbanairship.UAirship.access$000(UAirship.java:72)] [com.urbanairship.UAirship$2.run(UAirship.java:386)] [java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)] [java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)] [com.urbanairship.util.AirshipThreadFactory$1.run(AirshipThreadFactory.java:50)] [java.lang.Thread.run(Thread.java:920)] D/My Journey - UALib( 1821): PermissionsManager - Check permission display_notifications status result: granted D/My Journey - UALib( 1821): InAppRemoteDataObserver - Finished processing messages. D/My Journey - UALib( 1821): AutomationEngine - Updating triggers with type: 8 D/IMGGralloc( 1821): Gralloc Register w:720, h:1600, f:0x101, usage:0xb00, ui64Stamp:542475, sSize:4608000, line = 2376 D/InputMethodManager( 1821): prepareNavigationBarInfo() DecorView@2461049[MainActivity] D/InputMethodManager( 1821): getNavigationBarColor() Fail I/InputMethodManager( 1821): startInputInner - mService.startInputOrWindowGainedFocus

rlepinski commented 12 months ago
E/My Journey - UALib( 1821): Caused by: java.lang.IllegalStateException: WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.

You need to figure out what SDK/plugin/code is causing work manager to not work properly. I would remove that line you added, it basically breaks how work manager is supposed to set its self up. I still need the list of your dependencies and the output of ./gradlew app:dependencies and ill try to track down the issue for you

hemantchauhan commented 12 months ago

thanks @rlepinski. ok I was able to comment out the plugin which was causing the issue. build runs fine on the device now. but I still don't receive test push from go.airship.com. the logs are same as above. I have

Download the Firebase google-services.json file and place it inside android/app.
Applied the com.google.gms.google-services plugin in the app-level build.gradle file.

am I missing any other step?

rlepinski commented 12 months ago

Sounds like you are missing the google-services.json. https://docs.airship.com/platform/mobile/setup/configure-channels/#fcm

You have to download the google-services.json for the FCM project you are trying to send push through. The file needs to be in the root of the android app project