Try to do a Tools - Clean Project before you compile your app.
Also make sure to compile your app in Release mode.
Note that I never encountered such issue where an #AdditionalJar attribute is ignored.
Thanks Erel.
I don't know what happened on that day. If it didn't happen so many times, I would have thought that I was doing something wrong. But now it seems to be working fine. Maybe the computer needed an Easter break too!
It looks like this approach to collections widgets may work. Hopefully I will be able to get data from and to the widget from the application. I am not sure if I will be able to do it with JavaObject library. That's the next step.
The only issue I have is when I add the widget to the home screen and then update the application, the application is not responding.
If I remove the widget from the home screen and then update an application everything works fine.
I wonder, if it is because the application package is different from the jar package. Jar package is a (RemoteViewsFactory) RemoteViews service. Maybe during application update the service is not stopped?
Edit:
I did some more checking to find out what cause of the problem with application not responding and part of the log is below.
Start proc com.ListWidget for broadcast com.ListWidget/.WidgetProvider: pid=1961 uid=10148 gids={50148}
onReceive Action android.appwidget.action.APPWIDGET_UPDATE
buildLayout appWidgetId 133
Exception Ljava/lang/NullPointerException; thrown while initializing Lcom/ListWidget/R$layout;
Calling main entry com.android.commands.am.Am
START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.ListWidget/.main} from pid 1975
From the log, I think that the problem is the initializing widget layout resource (for widget service) which is started before main app.
The resources are generated in the R.java in jar using RGenerator2, for example:
public static final class layout {
public static int widget_provider_layout = BA.applicationContext.getResources().getIdentifier("widget_provider_layout", "layout", BA.packageName);
public static int widget_item = BA.applicationContext.getResources().getIdentifier("widget_item", "layout", BA.packageName);
}
Do I get BA.applicationContext before starting main in application? Or is it because of that, that I got NullPointerException?
I can't move widget_provider.xml file (and widgetlayout.xml file) to the jar file because they are referenced in the Manifest which has to be in the B4A project.
How could I resolve this issue? Any suggestions?