Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building android-kawa in Termux? #3

Open
panicz opened this issue Sep 16, 2021 · 2 comments
Open

Building android-kawa in Termux? #3

panicz opened this issue Sep 16, 2021 · 2 comments

Comments

@panicz
Copy link

panicz commented Sep 16, 2021

hi,

I have filed a smiliar issue in the KawaDroid project.

For a while, I have been working on a Scheme editor for Android. Recently, I managed to hook it to the Kawa evaluator, and I think the result is quite promising:

https://youtube.com/shorts/oOHg74HYau4?feature=share

The editor itself is implemented in Java, because I've been using the all-mighty Termux environment on my phone to build it.

I did so, because I've found the 'buildAPKs' project, which provides build scripts that allow to build APK files on Android devices.

Recently it occurred to me, that if I were using Kawa, I'd be able to work on the editor in itself, which I think would be beneficial in many ways.

However, I know fairly little about Kawa, Java and the Android ecosystem.

When I try to build the KawaHello project using the .jar file from the KawaDroid repo, i.e.

$ java -jar ../KawaDroid/app/libs/kawa.jar -C KawaHello/src/kawa/android/hello.scm

I get the following error:

        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1155)                                                                        at java.base/jdk.internal.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:42)                                     at java.base/jdk.internal.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:185)                                                      at java.base/java.lang.reflect.Field.acquireFieldAccessor(Field.java:1132)                                                                            at java.base/java.lang.reflect.Field.getFieldAccessor(Field.java:1113)                                                                                at java.base/java.lang.reflect.Field.get(Field.java:425)
        at gnu.expr.ModuleInfo.setupModuleExp(ModuleInfo.java:196)                 at kawa.standard.require.importDefinitions(require.java:301)               at kawa.standard.require.scanForDefinitions(require.java:197)              at kawa.lang.Syntax.scanForm(Syntax.java:57)                               at kawa.lang.Translator.scanForm(Translator.java:1508)                     at gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:82)              at gnu.expr.Compilation.process(Compilation.java:1935)                     at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:290)
        at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:272)
        at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:272)                   at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:272)                   at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:272)                   at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:272)
        at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:272)                   at kawa.repl.compileFiles(repl.java:824)                                   at kawa.repl.processArgs(repl.java:444)
        at kawa.repl.main(repl.java:871)                                   Caused by: java.lang.ClassNotFoundException: android.view.View                     at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)                                                            at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)                                                         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)         ... 25 more

I haven't followed your build instructions, and will try to figure out how to translate them to Termux, but do you think that building your project in Termux should in principle be possible?

@abarbu
Copy link
Owner

abarbu commented Sep 21, 2021

I haven't used this in many years. It could be that Kawa has changed sufficiently so that the code no longer works.

Although if you're having the same issue with another project, it's probably not that. Sorry. I don't remember enough to help debug this.

@panicz
Copy link
Author

panicz commented Sep 23, 2021

Thanks for your response! I'm trying to understand this ecosystem, but I still find it overwhelmingly confusing.

The problem with using kawa.jar from the KawaDroid project seems to be related mostly with their particular jar. I have tried the version of Kawa that is fetched by your script (1.13 IIRC), and after replacing the config.guess and config.sub files I managed to build it.

However, after the first iteration it failed to work, because the generated bytecode was incompatible (I think because it was using the features of Java8+). So I forced the java source to '1.7' and I didn't get errors with compatibility, but when I was building an apk containing that jar with the script from 'buildAPKs', the 'dx' command was taking very very very long time, and it ended with an "out of memory" exception.

I suspect that there might be some bug in the dexer for Java 7 byte code. I would preferably use Java 5, but unfortunately the java compiler from the Termux repo doesn't support it. I suppose this is why the 'buildAPKs' project uses the ecj compiler, rather than javac. However, I wasn't able to build kawa with ecj, because it was reporting that some libraries were missing.

Either way, I think that maybe we should keep this issue open, and if I manage to figure out how to make it work on Termux, I'll submit a patch (and I will just close it if I give up).

But if you had any suggestions, I'd appreciate it.

(BTW I saw your resume and I was very impressed. I wonder whether you still contribute to the Chicken ecosystem, or prefer to use Haskell these days, or maybe something else)

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

No branches or pull requests

2 participants