Dynamically loading a .jar file at Runtime

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Dynamically loading a .jar file at Runtime

Postby mmdumi » Tue Mar 23, 2010 10:04 am

I have a jar file in my app local data "/data/data/ro.lisamobile/files/
echo.jar".
I want to load the class "lisa.modules.echo.EchoModule" which resides
in my jar.

I am using java.net.URLClassLoader to load the class. On an non
android environment the code works, on android it gives me this
exception "can't load this type of class file".

Do you know why is that ?
Do i need to convert my jar file to dalvik bytecode ?

Thanks.
Below it's an output of Logcat:

03-22 14:46:53.676: WARN/file(779): file:/data/data/ro.lisamobile/
files/echo.jar
03-22 14:46:53.776: INFO/ActivityManager(563): Displayed activity
ro.lisamobile/.LisaMobile: 3976 ms
03-22 14:46:53.816: ERROR/dalvikvm(779): ERROR:
defineClass(0x4364dfe0, lisa.modules.echo.EchoModule, 0x436549a0, 0,
1, 0x43655b58)
03-22 14:46:53.826: WARN/System.err(779):
java.lang.UnsupportedOperationException: can't load this type of class
file
03-22 14:46:53.835: WARN/System.err(779): at
java.lang.VMClassLoader.defineClass(Native Method)
03-22 14:46:53.846: WARN/System.err(779): at
java.lang.ClassLoader.defineClass(ClassLoader.java:338)
03-22 14:46:53.865: WARN/System.err(779): at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
123)
03-22 14:46:53.875: WARN/System.err(779): at
java.net.URLClassLoader.findClassImpl(URLClassLoader.java:1220)
03-22 14:46:53.875: WARN/System.err(779): at
java.net.URLClassLoader$4.run(URLClassLoader.java:629)
03-22 14:46:53.875: WARN/System.err(779): at
java.net.URLClassLoader$4.run(URLClassLoader.java:628)
mmdumi
Freshman
Freshman
 
Posts: 9
Joined: Tue Aug 25, 2009 9:31 am
Location: Bucharest

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 8 guests