Thanks for your advice. I created an apk using the same classes and
installed it using adb install to Emulator. Now I tried to use the
following code to access the methods in Class SystemProperties which
is part of newly installed apk. I still got ClassNotFoundException:
public void test0method(){
DexClassLoader dLoader = new DexClassLoader(/data/app/
com.my.internal.apk,
/data/local/tmp, null,
ClassLoader.getSystemClassLoader());
try {
Class cLoad = dLoader.loadClass
(com.my.internal.SystemProperties);
// above line throw ClassNotFoundException
Method mLoad = cLoad.getMethod(GetString,new Class[]{});
Object obj = cLoad.newInstance();
Object sysProp = cLoad.newInstance();
mLoad.invoke(obj);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I peeked into the apk file and saw classes.dex there. Is there a way I
can dump the content of a dex file and to see if the classes are
there?
Thanks,
Sherry
On May 28, 12:43 pm, fadden fad...@android.com wrote:
On May 26, 4:00 pm, sherry syang...@gmail.com wrote:
I'm trying to dynamically load a jar file, then load the classes
inside the jar. The code is simple but I keep getting ClassNotFind
exception. The class is in the jar. How can I figure out what is
wrong?
Two thoughts come to mind:
(1) The Dalvik VM uses its own DEX format, not Java .class files. If
you have a Jar full of classfiles, it's not going to work. The VM
expects to find a single classes.dex in a jar file.
(2) For loading classes from DEX files outside your app's APK you
probably want to use DexClassLoader (introduced in 1.5).
URLClassLoader is not really useful for loading classes.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---