Hi Thanks firstly. Both project is running. In fact B is running, I try to instaniante A from B which lies in different apk. but it failed. The type should be "com.example.test".(Just a guess, I'll confirm tomorrow) Regarding "Is framework/base in project A or B?" , I think both. When I put com.example.test to framework/base(which mean extend android API), it works. Regards, Jove
On Mar 20, 1:26 pm, Greg Krimer <[email protected]> wrote: > Hi, I am confused. Which project is running A or B? Is > com.example.A.test1 in project A or B? > > What is the type of the object that you do create? Try this: > > Object tmp = c.newInstance(); > System.out.println(tmp); > > Is framework/base in project A or B? > > Finally, and this may not be important at all, but try using > Class.forName() instead of the class loader directly. > > On Mar 19, 4:03 am,Jove<[email protected]> wrote: > > > Hi guys, > > I meet a problem when using jar files, I simplify my question by > > below examples: > > > test.jar include a class of "com.example.test.class" > > eclipse project A using test.jar and declare test1 extend from > > com.example.test > > eclipse project B using test.jar too and declare test2 extend from > > com.example.test > > Both project build sucessfull. > > Then I try to using reflection in project B to instaniance a > > instance of test1 > > > Class <?> c = tmpCtxt.getClassLoader().loadClass > > ("com.example.A.test1"); > > test tmp = (test) c.newInstance() // > > it throw java.lang.ClassCastException. (but if I put > > com.example.test.class into frameworks/base", it's OK) > > Anyidea about this issue? > > Any advice is appreciated. > > > Regards, > >Jove --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

