Skip to content
This repository has been archived by the owner on Jul 26, 2018. It is now read-only.

How to create android specific .pgf_c binary ? #33

Open
androidsparkling opened this issue Apr 18, 2018 · 9 comments
Open

How to create android specific .pgf_c binary ? #33

androidsparkling opened this issue Apr 18, 2018 · 9 comments

Comments

@androidsparkling
Copy link

I am able to make .pgf file using the make command. But unable to find the tutorial/doc for creating .pgf_c binary from .pgf file.

@inariksit
Copy link
Member

I have no experience in GF with Android, but is there anything useful in this directory? https://github.com/GrammaticalFramework/GF/tree/master/src/ui/android

Maybe @krangelov or @johnjcamilleri could help?

@androidsparkling
Copy link
Author

androidsparkling commented Apr 18, 2018

Yes. I have seen the application in Playstore and saw the android sources in this repository. I have successfully built the JNI and android source. But when reading the source I found that .pgf_c binary needed for each language. So I installed GF 3.9 and successfully build gfo and pgf files, but I nowhere found any documentation for making .pgf_c binary from .pgf binaries.

String name = mLanguage.getConcrete()+".pgf_c"
in = mContext.getAssets().open(name);

@krangelov or @aarneranta or @johnjcamilleri any help ?

@inariksit
Copy link
Member

@androidsparkling I found it; you need to use the --split-pgf flag.

Here is an example:

$ gf -make --split-pgf LangDut.gfo LangSwe.gfo
linking ... OK
Writing Lang.pgf...
Writing LangDut.pgf_c...
Writing LangSwe.pgf_c...

@inariksit
Copy link
Member

I added a few lines to hopefully make the documentation clearer; you can see the changes here. If you have suggestions how to make it even clearer, or in which other place(s) this information should be available, just let me know and I can add it!

@androidsparkling
Copy link
Author

Great !. Thanks for your help. I can able to build .pgf_c files now.
Let me explain what I have done first,

  1. I have converted .gf files from the directory 'GF/examples/app/' using
    make command.

  2. After 'make' command executed I could see that there is a new folder 'gfo', the folder contains .gfo files corresponding to the languages. Also, there are pgf files generated inside the folder 'GF/examples/app/'. Even though some languages failed to generate the .pgf files.

  3. I have used --split-pgf command to generate .pgf_c file from the .pgf files and succeeded.

  4. So I have copied App.pgf, AppEng.pgf_c, and AppHin.pgf_c into assets folder and successfully build and installed on a device.

But I got an error when loading AppHin.pgf. (Tried Bulgarian, Chinese also but same error). See the logs on an Android device,

Translator: App.pgf loaded (618 ms)
Translator: Trying to load AppEng.pgf_c
Timeline: Timeline: Activity_idle id: android.os.BinderProxy@183341d3 time:26465724
Translator: AppEng.pgf_c loaded (2252 ms)
Translator: Trying to load AppHin.pgf_c

        --------- beginning of crash

AndroidRuntime: FATAL EXCEPTION: Thread-3934
Process: org.grammaticalframework.ui.android, PID: 30884
java.lang.NullPointerException: Attempt to invoke virtual method 'void ``org.grammaticalframework.pgf.Concr.load(java.io.InputStream)' on a null object reference
at org.grammaticalframework.ui.android.Translator$ConcrLoader.run(Translator.java:720)

When I tried Catalan I got the following native error.

D/Translator: Trying to load AppCat.pgf_c
org.grammaticalframework.ui.android A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 15249 (Thread-14094)
org.grammaticalframework.ui.android W/libc: Security Level: (1), Debug inforamtion is controlled by the DUMPABLE flag.

@inariksit
Copy link
Member

I've never done anything with Android, but could you try some more basic debugging?

  • Is there anything you can do with PGFs that does work? For instance, try the getLanguages() method on the PGF (not .pgf_c).
  • Can you try with another grammar? Something really simple, like a Foods grammar with just a single concrete syntax.
  • When did you install the C runtime and the Java bindings? There have been quite recent bugfixes, you could check that you have the most up-to-date version.

If you don't get answers here, you could post your problem to the gf-dev mailing list. I'm not sure how much @krangelov , @Thomas-H etc. follow GitHub issues.

@aarneranta
Copy link
Contributor

aarneranta commented Apr 19, 2018 via email

@krangelov
Copy link
Member

krangelov commented Apr 19, 2018 via email

@inariksit
Copy link
Member

@androidsparkling Did you get it to work? In the Java version, you can use getLanguages() method to check which languages are available.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants