Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve superclass error when referencing .jar library

  1. I did an Android project and run it. It ran successfully.
  2. I developed a web service in Java and hosted it. It ran successfully.
  3. I exported the webservice into a .jar and added it to my Android project.
  4. When I try to call a method in the web service I get an Unable to resolve superclass error.

My error log:

Unable to resolve superclass of Lweb/service/RandomWordGeneratorService; (73)
Link of class 'Lweb/service/RandomWordGeneratorService;' failed 
Could not find class 'web.service.RandomWordGeneratorService',
    referenced from method tam.miru.Login$1.onClick
VFY: unable to resolve new-instance 110 Lweb/service/RandomWordGeneratorService;)
    in Ltam/miru/Login$1; 
VFY: replacing opcode 0x22 at 0x005a    
VFY: dead code 0x005c-006e in Ltam/miru/Login$1;.onClick (Landroid/view/View;)
like image 451
sakthi Avatar asked May 29 '11 16:05

sakthi


5 Answers

Just started to get this issue after upgrading to ADT 17.

Discovered that external .jar files need to be in a 'libs' (with an s) folder otherwise their classes are not included in the .dex file that is created. Before the upgrade everything worked fine with my .jar files in a 'lib' folder (no s).

like image 59
rabidgremlin Avatar answered Nov 18 '22 20:11

rabidgremlin


In my case I had to go to Properties->Java Build Path->Order and Export and check Android Private Libraries, then cleaned the project and worked fine.

like image 40
Leonardo Pinto Avatar answered Nov 18 '22 21:11

Leonardo Pinto


Create lib folder, libs folder is for native libraries. I made it, add library to lib and to build path as internal library and it works!

like image 4
42n4 Avatar answered Nov 18 '22 21:11

42n4


Are you using eclipse? If so, did you add the library to the build path as described in Adding a library/JAR to an Eclipse Android project?

like image 2
Programmer Bruce Avatar answered Nov 18 '22 22:11

Programmer Bruce


I know that this a post on a really old thread, but after I read the answer by @rabidgremlin, I checked the folder structure, and found that it was already in "libs". However, on seeing the support.jar, I figured that using this was what was causing the issue.

I was extending "FragmentActivity" but it turns out, that was referencing the support.jar, which had issues in itself. Once I removed the extends clause, the app miraculously stopped crashing.

Just an FYI in case someone comes looking. Cheers!

like image 2
Sreedevi J Avatar answered Nov 18 '22 22:11

Sreedevi J