Android Question Compile To Library Alt+5 How to include JSON file in library

Discussion in 'Android Questions' started by jimmyF, May 17, 2019.

  1. jimmyF

    jimmyF Active Member Licensed User

    I have created my first library with the "Compile To Library" command.
    I make use of the B4XPreferenceDialog in the Class modules.

    Actually, the log error is the following:
    Code:
    Initialize: java.io.FileNotFoundException: /data/user/0/sef.test/files/virtual_assets/listtemplate.bal (No such file or directory)
    This is not a file that I use.

    btw, there was nothing found in my forum searches.
     
    Last edited: May 17, 2019
  2. Star-Dust

    Star-Dust Expert Licensed User

  3. jimmyF

    jimmyF Active Member Licensed User

    So, I am trying to load this file (I can see it in the jar(zip) file.):
    Code:
    prefdialog.LoadFromJson(File.ReadString(File.DirAssets, "login.json"))
    I have tried this but it tells me it is missing a parameter.

    Code:
    Dim sFile As String = File.DirAssets &  "login.json"
    prefdialog.LoadFromJson(
    File.ReadString(jf1.LoadFileFileFromJar(sFile)))
     
  4. DonManfred

    DonManfred Expert Licensed User

    try
    Code:
    Dim sFile As String = "login.json"
    prefdialog.LoadFromJson(jf1.LoadFileFileFromJar(sFile))
     
  5. jimmyF

    jimmyF Active Member Licensed User

    When jf1.Initialize(True):
    java.lang.RuntimeException: JSON Object expected.

    When jf1.Initialize(False):
    Too many errors with the loading of the B4XPreferencesDialog.

    I will drop this idea of compiling it into a library and simply use the classes I wrote directly in my apps.
    That way they work just fine.

    Many thanks for your help.

    -j
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You should create a b4xlib. It is a matter of creating a zip file with the modules. Unzip XUI Views.b4xlib for an example.
     
    jimmyF likes this.
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