Why do I get a class link that failed to import the jar into an Android project in Eclipse?

In Eclipse, I wrote a package of classes for use with Android and tested them in an Android project, saving the test code in the second package. Then I used the command line to create a jar file from all the cash desks in my project bin / classes directory (only for my library package, not for the test package). Running "jar tf" shows all classes correctly prefixed with my package name.

Then I created another Android project with activity that imported my first package and used methods, for example:

import uk.me.stevewaring.nestedsettings.NestedSettingsCommon; import uk.me.stevewaring.nestedsettings.NestedSettingsReformat; public class ShowNestedSettings extends Activity implements NestedSettingsReformat {... 

Then I right-clicked on my new project and used Build Path to add my jar. My jar is displayed at the top of the java build path in the Libraries section, and below the Order and Export.

As soon as I added my jar, all the red squiggly lines from lint complaining about the methods in my package disappeared.

However, when I try to debug my project, in LogCat I get:

 04-27 05:45:44.180: I/dalvikvm(14576): Failed resolving Lcom/example/shownestedsettings/ShowNestedSettings; interface 553 'Luk/me/stevewaring/nestedsettings/NestedSettingsReformat;' 04-27 05:45:44.210: W/dalvikvm(14576): Link of class 'Lcom/example/shownestedsettings/ShowNestedSettings;' failed 

and then fail because the class to run does not exist.

When I built the original project, I did not check the " Mark this project as a library " box, could this be a problem? I am not sure what effect this check box has. If this is a problem, is there a way to retrospectively apply this action or will I need to create a complete new project and copy my package into it before using it to create a jar. If this is not a problem, then what have I done wrong?

Additional info: I removed the interface implementation, then when I tried to debug, I got the following:

 04-27 05:52:10.919: I/dalvikvm(14677): Could not find method uk.me.stevewaring.nestedsettings.NestedSettingsCommon.initialise, referenced from method com.example.shownestedsettings.ShowNestedSettings.onCreate 04-27 05:52:10.949: W/dalvikvm(14677): VFY: unable to resolve static method 3566: Luk/me/stevewaring/nestedsettings/NestedSettingsCommon;.initialise (Landroid/app/Activity;)V 04-27 05:52:10.949: D/dalvikvm(14677): VFY: replacing opcode 0x71 at 0x0003 

which did not surprise me, NestedSettingsCommon.initialise was the first call of my activity made for code in my bank.

I also tried exporting the Jar from Eclipse, not from the command line. It didn't matter either.

+4
source share
1 answer

Make sure the JAR is configured to export with the application:

Project> Properties> Java Build Path> Order and Export

+15
source

Source: https://habr.com/ru/post/1480416/


All Articles