Android Question App dont' start

fishwolf

Well-Known Member
Licensed User
Longtime User
I'm receving some email about start failed of my app on some Samsung device (s7, a5, ecc,ecc)

From google console i see this error, i have release a month ago a new version with a better code for firebase notification

Suggestion?

Thanks

B4X:
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{a872b8f u0 myapp/.firebasemessaging}

B4X:
Sub Service_Start (StartingIntent As Intent)   
   
    If StartingIntent.IsInitialized Then
        Log("StartingIntent")
        fm.HandleIntent(StartingIntent)
    End If
   
    Sleep(0)
   
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
   
End Sub
 

fishwolf

Well-Known Member
Licensed User
Longtime User
Have you changed the automatic foreground mode to never?
Yes, in last version
in previous version i used B4A < 8 with this code

B4X:
Sub Service_Start (StartingIntent As Intent)
    
    If StartingIntent.IsInitialized Then
        Log("StartingIntent")
        fm.HandleIntent(StartingIntent)
    End If
    
    'Sleep(0)
    
    'Service.StopAutomaticForeground 'remove if not using B4A v8+.
    
End Sub
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
So your app will crash when starts from the background.

Carefully read the tutorial: Automatic Foreground Mode
i have read the tutorial, but don't understand what is the problem.

App start on all my devices (old and new) that i can run.
Why don't start on some devices
Is it the android version the problem?
i use the b4a ver. 9.50
My manifest is:
B4X:
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Have you set the automatic foreground mode to NEVER:
B4X:
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
?
no, i think of no, i have used the FirebaseMessaging service suggest into tutorial for Push notification
B4X:
Region  Service Attributes 
    #StartAtBoot: False
#End Region

Sub Process_Globals
Private fm As FirebaseMessaging
Dim NotifSound As SoundPool
Dim NotifID As Int
End Sub

Sub Service_Create
    fm.Initialize("fm")
    
    NotifSound.Initialize(2)
    NotifID = NotifSound.Load(File.DirAssets, "notification.wav")
    
End Sub

Public Sub SubscribeToTopics
Dim Topic As String
    
    Topic = Main.gParamEmail
    Topic = Topic.Replace("@", "-at-")
    fm.SubscribeToTopic(Topic)

End Sub

Sub Service_Start (StartingIntent As Intent)    
    
    If StartingIntent.IsInitialized Then
        Log("StartingIntent")
        fm.HandleIntent(StartingIntent)
    End If
    
    Sleep(0)
    
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
    
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Log($"Message data: ${Message.GetData}"$)
    
    If Message.GetData.Get("activity") = "Calendar" Then
        If Message.GetData.Get("lat") <> Null Then
            Main.gLatitude  = Message.GetData.Get("lat")
        End If
        If Message.GetData.Get("lon") <> Null Then
            Main.gLongitude = Message.GetData.Get("lon")
        End If
    End If    
    
    Dim n As Notification
    n.Initialize
    'n.Icon = "icon"
    
    n.Icon = "notification"
    n.Sound = False
    n.Vibrate = False
    n.Light = False
    n.OnGoingEvent = False
    n.AutoCancel = True
    
    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Message.GetData.Get("activity"))
        
    n.Notify(1)
    
    Sleep(1000)

    NotifSound.Play(NotifID, 1, 1, 1, 0, 1)
    
    Log ("RemoveCache")
    Common.RemoveCache
        
End Sub

Sub Service_Destroy

End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
is this the problem?
Why don't you upgrade to 9.80 anyway:
1. It is free. Worth upgrading even if it does not fix your problem
2. the old Msgbox syntax will still work and will not give you errors. They only give warnings. Then, when you solve your main problem, you can change them too.
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
I have installed 9.80, install some libraries for Firebase installation, datatransport, encoder-json ecc,ecc (warning to load project), but now don't start

B4X:
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: com.google.firebase.components.MissingDependencyException: Unsatisfied dependency for component Component<[class com.google.firebase.iid.FirebaseInstanceId]>{1, type=0, deps=[Dependency{anInterface=interface com.google.firebase.events.Subscriber, type=required, direct=true}, Dependency{anInterface=interface com.google.firebase.platforminfo.UserAgentPublisher, type=required, direct=true}, Dependency{anInterface=class com.google.firebase.FirebaseApp, type=required, direct=true}, Dependency{anInterface=interface com.google.firebase.installations.FirebaseInstallationsApi, type=required, direct=true}, Dependency{anInterface=interface com.google.firebase.heartbeatinfo.HeartBeatInfo, type=required, direct=true}]}: interface com.google.firebase.installations.FirebaseInstallationsApi
    at android.app.ActivityThread.installProvider(ActivityThread.java:6591)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6079)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5985)
    at android.app.ActivityThread.access$1200(ActivityThread.java:201)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1679)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6864)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: com.google.firebase.components.MissingDependencyException: Unsatisfied dependency for component Component<[class com.google.firebase.iid.FirebaseInstanceId]>{1, type=0, deps=[Dependency{anInterface=interface com.google.firebase.events.Subscriber, type=required, direct=true}, Dependency{anInterface=interface com.google.firebase.platforminfo.UserAgentPublisher, type=required, direct=true}, Dependency{anInterface=class com.google.firebase.FirebaseApp, type=required, direct=true}, Dependency{anInterface=interface com.google.firebase.installations.FirebaseInstallationsApi, type=required, direct=true}, Dependency{anInterface=interface com.google.firebase.heartbeatinfo.HeartBeatInfo, type=required, direct=true}]}: interface com.google.firebase.installations.FirebaseInstallationsApi
    at com.google.firebase.components.ComponentRuntime.validateDependencies(com.google.firebase:firebase-components@@16.0.0:170)
    at com.google.firebase.components.ComponentRuntime.processInstanceComponents(com.google.firebase:firebase-components@@16.0.0:89)
    at com.google.firebase.components.ComponentRuntime.<init>(com.google.firebase:firebase-components@@16.0.0:73)
    at com.google.firebase.FirebaseApp.<init>(com.google.firebase:firebase-common@@19.3.0:418)
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:300)
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:268)
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:253)
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@19.3.0:51)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1928)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1903)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@19.3.0:45)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6586)
    ... 10 more
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
on other machine don't compile the java code

B4X:
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/AbstractComponentContainer;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/Component;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/Component$$Lambda$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/Component$$Lambda$2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/Component$$Lambda$3;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/Component$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/Component$Builder;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/ComponentContainer;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/components/ComponentDiscovery;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:692)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
    at com.android.dx.command.dexer.Main.runDx(Main.java:293)
    at com.android.dx.command.dexer.Main.main(Main.java:249)
    at com.android.dx.command.Main.main(Main.java:94)
Caused by: java.lang.InterruptedException: Too many errors
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:684)
    ... 4 more
 
Upvote 0
Top