Problem with linking to other project in Android E

2020-07-23 03:39发布

问题:

I am developing an Android application as an Eclipse project that uses classes from another Eclipse Android project I already have. When I originally imported it (New Project > Android Project > From Existing Source), it had a bunch of errors, but when I did Project > Properties > Java Build Path and went to the projects tab and added the other project, the errors went away. Unfortunately, when I ran the application, I got the following error in DDMS:

java.lang.NoClassDefFoundError: [package name].Config
[stack trace]

Is there something I'm supposed to add to the manifest telling it to look at the other package? If so, where would that be added?

Thanks in advance

回答1:

Found the answer. It turns out that if I add the compiled class files into a JAR file using Eclipse's export command and then link to external jars in the Java Build Path, it works without having to change the Android Manifest at all.



回答2:

Try using the File -> Import...

Then go to "Existing projects into Workspace" and choose the root directory of the project. The one where are the src,res... folders



回答3:

Your second project should be a library. Open project properties, select the Android tab and check "is library".

In your main project, open its properties, select Android tab also and click on Add in the library section and add your second project.