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]

NullPointerException on android when calling load


Howdy -

I'm trying to implement a very half baked idea on Android, and ran
into an exception which makes me think I'm doing something I shouldn't
be doing.

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.

I had no problem getting the basic skeleton app in place (great
Android instructions, by the way!).  You can see the entire project
here: https://github.com/benjisimon/app-doh

The code that's giving me trouble is in the project's main (and only) .scm file:

(require 'android-defs)
... some definitions removed...
(define-simple-class main (android.app.Activity)
  ((onCreate (savedInstance :: Bundle))
   (invoke-special android.app.Activity (this) 'onCreate savedInstance)
   (prep-directories)
   (let* ((on-create-scm (app-doh-path "creation/on-create.scm"))
          (ready? (file-exists? on-create-scm)))
     (if ready?
       (load on-create-scm)  ; [1] *******
       ((this):setContentView
        (android.widget.TextView (this)
                                 text: (string-append "Doing nothing.
File not found: " on-create-scm)))))))

I get an exception when invoking (load ...) at [1] above.

Here's the stack trace:

java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.benjisimon.appdoh/com.benjisimon.appdoh.main}:
java.lang.NullPointerException
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2453)
    at android.app.ActivityThread.access$900(ActivityThread.java:173)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5579)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
    at gnu.mapping.InheritingEnvironment.lookupInherited(InheritingEnvironment.java:48)
    at gnu.mapping.InheritingEnvironment.getLocation(InheritingEnvironment.java:76)
    at gnu.mapping.Environment.getLocation(Environment.java:117)
    at gnu.mapping.Environment.lookup(Environment.java:99)
    at gnu.mapping.Environment.get(Environment.java:175)
    at gnu.mapping.Environment.get(Environment.java:232)
    at kawa.Shell.openFile(Shell.java:404)
    at kawa.Shell.runFile(Shell.java:511)
    at kawa.standard.load.apply2(load.java:67)
    at kawa.standard.load.apply1(load.java:27)
    at com.benjisimon.appdoh.main.onCreate(main.scm:36)
    at android.app.Activity.performCreate(Activity.java:5451)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
    ... 11 more

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?)

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.

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).

Thanks for any assistance! (And sorry if I've made any rookie mistakes
with my posting the above question...)


-- 
Have an idea for software?  I can make it happen -
http://www.ideas2executables.com
My Blog: http://www.BlogByBen.com


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