Android Question The application ... has stopped unexpectedly.

henry1311

Member
Licensed User
Longtime User
I'm trying to develop a widget. I started with the example of the tutorial HomeScreen widgets ...
I simulated a screen for configuring the parameters.
In practice, tap on widget and screen appears with a label, EditText and buttons.
All Ok.
Every time I turn off and power back up the smartphone and tap on the widget, and i see this error and i can not log in anymore except reinstalling it.


The application Homescreen (process anywheresoftware.b4a.samples.homewidgets) has stopped unexpectedly.
Please try again.

Force close button

Thanks for the help
Enrico
 

Attachments

  • homewidgets_p1.zip
    11.4 KB · Views: 125

NJDude

Expert
Licensed User
Longtime User
Check the UNFILTERED logs to see what's causing the error. (on the IDE, bottom right, click on the LOGS tab and UNCHECK the FILTER box)
 
Upvote 0

henry1311

Member
Licensed User
Longtime User
Thank you very much NJDude!
Log unfiltered and this is actually seeing that the problem lies in the fifth line:

<!> anywheresoftware.b4a.BA 474 <!> ~ e: java.lang.RuntimeException: Object Should be initialized first (Map).

this (Map) is the declaration of a library in the Main module.

Question :
In a widget, disconnecting and reconnecting power the smartphones, the variables measured in the Main module are always available in the other modules as a normal app?
I do not think so because I get always the error that the variable is not valued.
So what is the strategy to develop a widget that makes use of enhanced interaction with fields, activity, etc..?

Thanks for the help
Enrico


Log :

Start proc anywheresoftware.b4a.samples.homewidgetsp1 for service anywheresoftware.b4a.samples.homewidgetsp1/.widgetservice: pid=4192 uid=10072 gids={}
<!>anywheresoftware.b4a.BA 474<!> ~i:** Service (widgetservice) Create **
write blocked for 282 msecs, 13 delayed writes, thread 0xce08
<!>anywheresoftware.b4a.BA 474<!> ~i:** Service (widgetservice) Start **
<!>anywheresoftware.b4a.BA 474<!> ~e:widgetservice_setlabel (java line: 147)
<!>anywheresoftware.b4a.BA 474<!> ~e:java.lang.RuntimeException: Object should first be initialized (Map).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
at anywheresoftware.b4a.objects.collections.Map.ContainsKey(Map.java:118)
at de.amberhome.locale.AHTranslator.GetText(AHTranslator.java:112)
at anywheresoftware.b4a.samples.homewidgetsp1.widgetservice._setlabel(widgetservice.java:147)
at anywheresoftware.b4a.samples.homewidgetsp1.widgetservice._imageview1_click(widgetservice.java:93)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.RemoteViewsWrapper.raiseEventWithDebuggingSupport(RemoteViewsWrapper.java:137)
at anywheresoftware.b4a.objects.RemoteViewsWrapper.HandleWidgetEvents(RemoteViewsWrapper.java:114)
at anywheresoftware.b4a.samples.homewidgetsp1.widgetservice._service_start(widgetservice.java:137)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.samples.homewidgetsp1.widgetservice.handleStart(widgetservice.java:65)
at
 
Last edited by a moderator:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that the error should also appear in the filtered logs.

The process can be killed from time to time. The service is then created when needed (when you click on the widget for example). In that case the code in Activity_Create is never called as the activity was not created. You should initialize AHTranslator in Service_Create.
 
Upvote 0

henry1311

Member
Licensed User
Longtime User
Everything works correctly.
All libraries and classes must be declared in Service_Start
Thanks for the help
Enrico

PS :
I was wrong to write :
NOT declared, but INITIALIZED in Service_Create!!!
I'm sorry!
Thank you Erel!
 
Last edited:
Upvote 0
Top