Android Question How to create library?

Theera

Well-Known Member
Licensed User
Longtime User
I tried to create ThaiMoney library by slc tools,but it created only jar file. It can't create xml file ,too. How do I do?
 

Attachments

  • ThaiMoney.zip
    6.5 KB · Views: 190
Last edited:

MikeSW17

Active Member
Licensed User
Longtime User
Libraries are stored in jar files. A jar file is basically a ZIP file.
If you've created the library correctly, you just need to copy the jar file into the appropriate 'Additional Libraries' folder, probably the /B4A sub folder.
Provided you've configured the Additional Folders in the IDE, your library should appear in the Libraries pane of the IDE.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
If you've created the library correctly, you just need to copy the jar file
No, the XML file is needed for B4A to identify it as a library.

Have you downloaded this? It includes a sample library that should compile to a jar and an xml file and place them in your additional libraries folder. If that works you can model your library on that.
Note that for libraries you should use Java 8 to compile (SLC uses the Java presently selected in B4A IDE) as BADoclet can produce corrupted xml files on later Javas.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
After I changed Java8,I can make both of them. When I run my library,it has error. I try change encoding UTF8 and UTF8 BOM,but I can't solve it.
 

Attachments

  • Error.png
    Error.png
    17.9 KB · Views: 187
Upvote 0

agraham

Expert
Licensed User
Longtime User
I've tried compiling the source above and get the same problem. If you delete the comment in getText I get a slightly different error

error: unmappable character for encoding Cp1252

The jar has compiled properly but it looks to me like BADoclet, which produces the xml file, is trying to map the UTF8 characters in ThaiMoney.java to an 8 bit code page and is trying to guess which one and then failing to map the Thai characters. Erel needs to look at this.

For the time being try saving the compiled jar in the additional libraries. Then edit the source to remove the Thai comment in getText and empty the three arrays of Thai characters then compile again. This produces the xml, attached below, and a new jar in additional libraries. Replace the new jar with the original compiled jar and hopefully it should work.
 

Attachments

  • ThaiMoney.xml
    1.8 KB · Views: 141
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
I have test it already,but I didn't work for me. However,I will redo all new again. Thank you,Agraham.
 
Upvote 0
Top