I wanted to add a ListView (or StackView) widget to my application. I was thinking about creating a library but with my Java knowledge it was too hard.
The other option that I thought about was to create an Eclipse project using compiled B4A java source code, and add to it ListView widget java files. But because I use quite a few libraries, after building the application in Eclipse it didn't run - coming with some errors of "class not found" etc.
So, I thought that maybe creating a jar with the ListView widget and including this jar in the B4A project using #AdditionalJar option would solve the problem.
I created a simple application in which I added an external Jar using #AdditionalJar option. I am not doing anything with this jar in main activity at this stage.
After building and running the application I get errors (sometimes) when I try to add the widget on the Home screen:
The problem is that I build an application again and it will be working OK. It happens randomly. I can build it 5 times and out of 5 times I can get one or two builds working. I don't change anything in the code before each build.
To find out what the problem was, I decompiled the working and not working application and noticed that in not working application the additional jar wasn't included in the built application (see attached photo).
I then tried the same thing with another application and including a jar file with StackView widget. And the same thing happens.
Any suggestions why this happens? Is it because I am not doing anything with this jar in main activity, so it is not included in the built application? But then again, why sometimes it is included?
The other option that I thought about was to create an Eclipse project using compiled B4A java source code, and add to it ListView widget java files. But because I use quite a few libraries, after building the application in Eclipse it didn't run - coming with some errors of "class not found" etc.
So, I thought that maybe creating a jar with the ListView widget and including this jar in the B4A project using #AdditionalJar option would solve the problem.
I created a simple application in which I added an external Jar using #AdditionalJar option. I am not doing anything with this jar in main activity at this stage.
After building and running the application I get errors (sometimes) when I try to add the widget on the Home screen:
B4X:
java.lang.RuntimeException: Unable to instantiate receiver com.ListWidget.WidgetProvider: java.lang.ClassNotFoundException: Didn't find class "com.ListWidget.WidgetProvider" on path: DexPathList[[zip file "/data/app/my.test.List-2.apk"],nativeLibraryDirectories=[/data/app-lib/my.test.List-2, /system/lib]]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2388)
at android.app.ActivityThread.access$1700(ActivityThread.java:135)
....
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ListWidget.WidgetProvider" on path: DexPathList[[zip file "/data/app/my.test.List-2.apk"],nativeLibraryDirectories=[/data/app-lib/my.test.List-2, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
... 10 more
To find out what the problem was, I decompiled the working and not working application and noticed that in not working application the additional jar wasn't included in the built application (see attached photo).
I then tried the same thing with another application and including a jar file with StackView widget. And the same thing happens.
Any suggestions why this happens? Is it because I am not doing anything with this jar in main activity, so it is not included in the built application? But then again, why sometimes it is included?