1

let me tell you that I'm new in Java and I'm having this problem with an Android App.

The app is made by two projects, the launcher activity(Project A) and another one (Project B) which has some common SRCs for multiple Android Apps (like http connection classes, etc).

I imported project B from A, and in my .java files of my project A, I could import without problem src from B (import path from B;)

But when I'm debbuging and it has to use a file from B, I get an NoClassDefFoundError with the path of some file in project B.

After that, my app fails and closes.

Sorry if my English is complicated. Hope you understand my problem and can help me.

I guess it's something about a missing step in my import.

3 Answers3

0

Please make sure you include the classes/src from project B in your project A's build path , by right clicking on your project A "Build Path" -> "Configure Build Path". Eclipse automatically will add those classes to your class path too.

The NoClassDefFoundError usually occurs when the classes needed to compile the project are present during build time but missing during run time.

Hope this helps !!

Chiseled
  • 2,280
  • 8
  • 33
  • 59
0

To reference other projects source in current project, just import them into your current project by adding them to your workspace. This link has some neat steps to accomplish this. You can follow which one suites you.

Community
  • 1
  • 1
BDRSuite
  • 1,594
  • 1
  • 10
  • 15
0

Importing just puts these projects into your workspace. If they are 2 separate projects you should import them as separate projects. Either right click import and navigate to them on your file system or if they are already in your workspace, do create new java project and give it the same name as the directory of the project (The wizard will make it clear that it recognizes a java project exists in that folder).

Then check to make sure that the package names and imports one package to the other are correct. If they weren't you should errors marked on those lines.

Finally make sure that the project which you are actually running from has the other project on its build path. Right click on the project, configure build path, and add the packages. Alternatively you can use something like maven to automate the installation of this second package as a jar which will automatically update in project A when project B is changed)

Roger
  • 10,851
  • 3
  • 26
  • 39
  • Thanks! Let me see if I got you right. You're saying that I have to create a new Project with the name of my A project (main project) and use this project to run? – Julián Gutiérrez Ostrovsky Oct 27 '14 at 18:39
  • Since project A requires code from project B, you will need to create both projects in this fashion. Then you will need to run it using one of the methods described in this article http://developer.android.com/training/basics/firstapp/running-app.html. If this were a regular java program you would run the class with a main method in it, or if this were a webapp you would run it on an app server like jboss or tomcat. – Roger Oct 28 '14 at 15:08
  • Thanks a lot! I'm trying that now – Julián Gutiérrez Ostrovsky Oct 29 '14 at 13:15