Android Question Unfortunately "App Name" has Stopped

Discussion in 'Android Questions' started by iCAB, Jan 17, 2015.

  1. iCAB

    iCAB Well-Known Member Licensed User

    Hello There

    I am trying to display a notification message to the end user when a push notification message is received by the app
    1. if the app is running in Foreground no issues
    2. If the app is running in background no issues
    Whoever if the user terminates the app using the task manager, upon receiving a notification message, I always get the following message displayed "Unfortunately "App Name" has Stopped" .

    The code sets some global variables and executes the code below to display a notification for the user
    Code:
    NotificationInfo.Initialize
       NotificationInfo.Icon = 
    "icon"
       NotificationInfo.Light = 
    True
       NotificationInfo.Sound = 
    True
       NotificationInfo.Vibrate = 
    True
       NotificationInfo.SetInfo(
    "iAppName", strMessage, Main)
       NotificationInfo.Notify(
    1)
    The icon and the message are displayed as expected.
    Is there a way to suppress this message?

    Thanks for your help
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should check the logs and post the error message.
     
  3. iCAB

    iCAB Well-Known Member Licensed User

    Hi Erel

    Here is what it captured

    ** Activity (main) Pause, UserClosed = false **


    Program compiled in debug mode, can only run with debugger attached.


    ** Service (pushservice) Create **


    java.lang.RuntimeException: Unable to create service hidata.iCABLTE.pushservice: java.lang.RuntimeException: java.lang.Exception: Sub service_create signature does not match expected signature.
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2435)
    at android.app.ActivityThread.access$1700(ActivityThread.java:140)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4947)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.RuntimeException: java.lang.Exception: Sub service_create signature does not match expected signature.
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:148)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:158)
    at hidata.iCABLTE.pushservice.onCreate(pushservice.java:45)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2425)
    ... 10 more
    Caused by: java.lang.Exception: Sub service_create signature does not match expected signature.
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:123)
    ... 13 more
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Check the signature of Service_Create. It should be:
    Code:
    Sub Service_Create
     
  5. iCAB

    iCAB Well-Known Member Licensed User

    I am not sure I fully understand what the signature mean in this case, but here is the code I am using

    Code:
    Sub Service_Create
       
    End Sub

    Sub Service_Start (StartingIntent As Intent)
        
    Select StartingIntent.Action
       
            
    Case "com.google.android.c2dm.intent.REGISTRATION"
                HandleRegistrationResult(StartingIntent)
               
            
    Case "com.google.android.c2dm.intent.RECEIVE"
                MessageArrived(StartingIntent)
               
        
    End Select
    End Sub
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You should compile in release mode in this case as the process is killed and then restarted because of the push message.
     
  7. iCAB

    iCAB Well-Known Member Licensed User

    I definitely did try that (several times ) before I posted the issue I am facing.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    You will not get this error in release mode. Maybe a different one.
     
  9. iCAB

    iCAB Well-Known Member Licensed User

    Hi Erel, Here is the error captured with release mode

    ** Service (pushservice) Create **


    ** Service (pushservice) Start **
    New message arrived: Bundle[{loc=43.804560,-79.297935, from=173276336318, alert=test, sound=alarm, collapse_key=DNM_LOC}]


    java.lang.RuntimeException: Object should first be initialized (List).


    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
    at anywheresoftware.b4a.objects.collections.List.getSize(List.java:129)
    at hidata.iCABLTE.filehandler._fh_setl_getsettingitem(filehandler.java:1894)
    at hidata.iCABLTE.settings._set_getsetting(settings.java:377)
    at hidata.iCABLTE.httpmessages._mmhf_builddriverstatus(httpmessages.java:417)
    at hidata.iCABLTE.pushmessages._pm_decodehostmessage(pushmessages.java:396)
    at hidata.iCABLTE.pushservice._messagearrived(pushservice.java:191)
    at hidata.iCABLTE.pushservice._service_start(pushservice.java:268)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:158)
    at hidata.iCABLTE.pushservice.handleStart(pushservice.java:68)
    at hidata.iCABLTE.pushservice.onStartCommand(pushservice.java:53)


    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2864)
    at android.app.ActivityThread.access$2100(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    java.lang.RuntimeException: Unable to start service hidata.iCABLTE.pushservice@29d92c8a with Intent { cmp=hidata.iCABLTE/.pushservice (has extras) }: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (List).
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2881)
    at android.app.ActivityThread.access$2100(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (List).
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:200)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:158)
    at hidata.iCABLTE.pushservice.handleStart(pushservice.java:68)
    at hidata.iCABLTE.pushservice.onStartCommand(pushservice.java:53)
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2864)
    ... 9 more
    Caused by: java.lang.RuntimeException: Object should first be initialized (List).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
    at anywheresoftware.b4a.objects.collections.List.getSize(List.java:129)
    at hidata.iCABLTE.filehandler._fh_setl_getsettingitem(filehandler.java:1894)
    at hidata.iCABLTE.settings._set_getsetting(settings.java:377)
    at hidata.iCABLTE.httpmessages._mmhf_builddriverstatus(httpmessages.java:417)
    at hidata.iCABLTE.pushmessages._pm_decodehostmessage(pushmessages.java:396)
    at hidata.iCABLTE.pushservice._messagearrived(pushservice.java:191)
    at hidata.iCABLTE.pushservice._service_start(pushservice.java:268)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    ... 13 more
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    The error happens in: filehandler._fh_setl_getsettingitem
    You are accessing an uninitialized List.

    You need to understand that the process was killed and restarted from the service. Activity_Create in the main code was not called.
     
  11. iCAB

    iCAB Well-Known Member Licensed User

    Thanks Erel that solved my problem
     
  12. Eksatech

    Eksatech Member Licensed User

    I am new, sorry about this question but You wrote something about this message and believe me I tried a lot of things you wrote, but still I am living same problem, I can't start application with release compile.

    When I compile in Debug (rapid) mode everything normal and application is working.

    When I release the application, device says "Unfortunately "App Name" has Stopped". After Release compile the log window as this:

    Installing file.
    GC_CONCURRENT freed 419K, 10% free 11361K/12487K, paused 3ms+12ms, total 34ms
    GC_CONCURRENT freed 410K, 10% free 11345K/12487K, paused 1ms+3ms, total 17ms
    GC_CONCURRENT freed 410K, 10% free 11353K/12487K, paused 4ms+2ms, total 31ms
    GC_CONCURRENT freed 426K, 10% free 11345K/12487K, paused 14ms+2ms, total 34ms
    GC_CONCURRENT freed 402K, 10% free 11345K/12487K, paused 4ms+4ms, total 35ms
    GC_CONCURRENT freed 402K, 10% free 11345K/12487K, paused 4ms+4ms, total 35ms
    GC_CONCURRENT freed 410K, 10% free 11353K/12487K, paused 14ms+2ms, total 36ms
    GC_CONCURRENT freed 346K, 9% free 11441K/12487K, paused 14ms+5ms, total 44ms
    PackageAdded: package:eksatech.Butterfly

    What is wrong, I can't understand. Can anyone helps me ?

    Thanks in advance.
     
  13. Eksatech

    Eksatech Member Licensed User

    I solved the problem. It is interesting but If you declare a process variable and you didn't use it at the right of equal sign B4A see the variable isn't used ???

    For Example:
    if you declare : Dim UserID as Int at the Process Variables and use it in the code

    UserID = 0, B4A says UserID isn't used, but if you equal it to another variable like: ProductID = UserID then for B4A no problem.

    Why like that ?
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    It shouldn't matter where you assign the value. However this is not related to this thread so please start a new one.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice