crisskiamryo / jythonroid

Automatically exported from code.google.com/p/jythonroid
Other
0 stars 0 forks source link

Dalvik VM unable to locate class 'org/python/util/jython' #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Running on an actual phone, running android rc30 (post root-typing bug),
adb shell gets me a shell that runs as id shell:
> $ id
> uid=2000(shell) gid=2000(shell)
groups=1003(graphics),1004(input),1007(log),1011(adb),3003(inet)

and can't read /data:
> /data:
> opendir failed, Permission denied

leading to dalvikvm failing to start jython:

$  dalvikvm -classpath /data/app/Jythonroid.apk org.python.util.jython 
 dalvikvm -classpath /data/app/Jythonroid.apk org.python.util.jython 
Dalvik VM unable to locate class 'org/python/util/jython'
java.lang.NoClassDefFoundError: org.python.util.jython
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.python.util.jython in
loader dalvik.system.PathClassLoader@40019600
    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:215)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:453)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:421)
    ... 1 more

(Using the 16-Nov-2008 build.) This makes it difficult to use
interactively...  is there any trick to get around this?  Or are we stuck
until the edit box works?

(What I *actually* want is to be able to write standalone applications with
this - even if that means embedding jython in them - maybe having the
default app use a little python code to display something, which we could
then extend and rebuild?)

Thanks...

Original issue reported on code.google.com by eic...@gmail.com on 16 Nov 2008 at 6:03

GoogleCodeExporter commented 9 years ago
oh it looks like you do not have the write permision on the /data fold, so try 
to change the path define in org/python/util/debug/FixMe.java
or you can give me a path where you can read and write, i will change the path 
for you
                                                    
     regards

Original comment by juanzhew...@gmail.com on 16 Nov 2008 at 6:32

GoogleCodeExporter commented 9 years ago
Actually I don't even have *read* permission.  Looks like /sdcard, /system 
(maybe
/system/framework? there are a bunch of .jar and .odex files there... or
/system/app.) Those are about it, based on an ls -R / from the adb shell.  (I 
haven't
tested the package build yet, I'll try and get to that later)

Original comment by eic...@gmail.com on 16 Nov 2008 at 11:23

GoogleCodeExporter commented 9 years ago
Hello,

what files are /data/app on your phone? 
> dalvikvm -classpath /data/app/Jythonroid.apk org.python.util.jython 
I'm wondering about the Jythonroid.apk. Is this file exists?

Google suggest the functions openFileInput and openFileOutput to read/write 
files. I don't know, where this 
files were created, so I found it out with this code (in an activity):
<code>
        try {
            FileOutputStream out = this.openFileOutput("test.txt", Application.MODE_WORLD_WRITEABLE);
            Log.e("gucken", this.getApplicationContext().getFilesDir().getAbsolutePath());
            out.write(1);
            out.flush();
            out.close();
            File f = new File("/data/data/de.local.andy/files/test2.txt");
            f.createNewFile();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
</code>
The files are generated at /data/data/NameOfYourApkWithoutExtension/files/

I got the Interpreter running, my APK is named org.python.util.apk here are my 
FixMe-Settings:
<code>
    public static final String apkpath = "/data/app/";
    public static final String apkname = "org.python.util.apk";
    public static final String apppath = apkpath + apkname;
    public static final String tmpdirpath = "/data/jythonroid/";
</code>
The directory /data/jythonroid/ was created from me by hand (mkdir 
/data/jythonroid)

Then, I replaced this line:
File fff = new File("/data/jvm.class");
with
File fff = new File("/data/data/org.python.util/files/jvm.class");
(Adjust the path for your settings)

That is working for me. (Okay, one warning about a buffer size, but it's 
running).

Hope this helps.

Greetings from Germany, Neq

Original comment by nequiq...@googlemail.com on 18 Nov 2008 at 9:30

GoogleCodeExporter commented 9 years ago
Hm, no edits for comments?

> Then, I replaced this line:
> File fff = new File("/data/jvm.class");
> with
> File fff = new File("/data/data/org.python.util/files/jvm.class");
> (Adjust the path for your settings)

forget to say, this line is located in the function getDexClass in in FixMe.java

Greetings from Germany, Neq

Original comment by nequiq...@googlemail.com on 18 Nov 2008 at 9:35

GoogleCodeExporter commented 9 years ago
thanks for you tips, because i do not even get a real phone now, i can only 
promise 
it runs on the emulator.
and i am not so familar with the way android handle files, thanks for you tips, 
and 
i am wondering whether there is a way to get the apk absolute path in 
android?if we 
can get that path, the configuration will be automatically.

and the jvm.class seems useless in the program, i will delete it in next update.

by the way i am forcusing on fix the "from package import *" probleam, it seams 
like such problem was caused by the java.lang.Package.getPackeges() bug of the 
android.
                                                        regards

Original comment by juanzhew...@gmail.com on 18 Nov 2008 at 10:36

GoogleCodeExporter commented 9 years ago
Hi,

one note, I also have no real phone, it will introduced in germany in first 
quarter of 2009.
The full path to the apk file can get with this (inside of an activity):

this.getApplication().getPackageCodePath()

returns /data/app/de.local.andy.apk on my app.

hope this helps.

Greetings, Neq

Original comment by nequiq...@googlemail.com on 18 Nov 2008 at 10:50