This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: NullPointerException on android when calling load




On 11/17/2014 10:03 AM, Ben Simon wrote:
Here's the idea: I've got visions of a skeleton Android app  that
starts up and basically does one thing: load a .scm file off external
storage.  In my mind's eye, this results in an application who's
actual functionality is driven by the .scm file.  While this wouldn't
be useful for production code, I think it would make for a fun way to
prototype apps right on the device. Basically, it's a REPL, but using
a static file instead of being interactive.

Just be aware that we can't create bytecode on-the-fly in Android, so
load (or eval) has to use the Kawa interpreter, which doesn't have the
same or full functionality (compare to the compiler), and which gets less testing.
(On regular Java the interpreter is mainly used for expanding syntax-case
macros.)

I trace the problem to this line of code in Shell.java:

         Object conv = Environment.user().get("port-char-encoding");

So, the app is crashing because the environment can't figure out the
encoding to use. (Or is it that there's no user environment setup?)

Looks like the latter.  Kawa should use sane encoding defaults.

Any suggestions for how to proceed?  I feel like I'm running into a
similar issue as this thread: http://bit.ly/1ERREMp - but the fixes
suggested there didn't change the error I was running into.

I'm not an export on Android development or debugging.  If you haven't already
done do, read the "Some debugging notes" section here:
http://www.gnu.org/software/kawa/Building-for-Android.html#Some-debugging-notes
I.e. you can add System.err.println or Log.i statements and view the results
with adb logcat.

The first step is figuring out why either inherited or inherited[i] is null
even though numInherited>0.

And assuming I can get load to function, any idea how I can pass the
current activity to code?  I was thinking something like:


  (fluid-let ((the-activity (this)))
   ...)

but that may be way off (and gives me a different NPE than the one above).

fluid-let is a bit tricky/ugly - you have to understand both Kawa's static scoping
and dynamic environment.  Cleaner and more modern is to define a parameter:

http://www.gnu.org/software/kawa/Parameter-objects.html

As a matter of fact (require 'android-defs) define a parameter
current-activity so that (current-activity) returns the current Activity (if any).
At least in the body of on-create and on-create-view.

I'll add the current-activity to the documentation.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]