Class files from library project missing in .apk

Put your problem here if it does not fit any of the other categories.

Class files from library project missing in .apk

Postby grbrg » Sat Aug 28, 2010 9:45 am

Hi all,

this week I've tried to convert one of my existing projects into a library project, and use this library in my app project. I basically followed all the steps in Google's description, and everything looks good in Eclipse: The compiler is happy, no errors.

The thing is: An .apk file is generated, which is missing all classes from the library project! Everything else is there, resources and the R file from both projects - but not the classes from the library.

After my research in the last days I only found one thing that looks weird (apart from the ClassNotFoundException when trying to run the app), which is the console output when starting the app in the emulator:
Code: Select all
[2010-08-27 21:13:02 - com.grbrg.MyApp] Installing com.grbrg.MyApp.apk...
[2010-08-27 21:13:11 - com.grbrg.MyApp] Success!
[2010-08-27 21:13:12 - com.grbrg.MyLib] Could not find com.grbrg.MyLib.apk!
[2010-08-27 21:13:12 - com.grbrg.MyApp] Starting activity com.grbrg.MyApp.MainActivity on device
...
Seems like Android is looking for the .apk file of MyLib project. MyLib is declared as Android library project, so it of course does not have an .apk file!

Does anyone have an idea what's wrong here? Any help is appreciated very much! :)
grbrg
Developer
Developer
 
Posts: 34
Joined: Mon Jul 13, 2009 1:55 pm

Top

Re: Class files from library project missing in .apk

Postby jonbonazza » Sat Aug 28, 2010 10:10 pm

When you export it, export it as a non-bootable JAR file. Not an Android APK.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: Class files from library project missing in .apk

Postby grbrg » Sun Aug 29, 2010 1:31 pm

Not sure how that is supposed to help, since I need an apk file.

However, I seem to have found a work-around: The source directory of the library project needs to be added as a linked source into the app project. I would have a assumed the Android Plugin does this, but for it works for me.
grbrg
Developer
Developer
 
Posts: 34
Joined: Mon Jul 13, 2009 1:55 pm

Re: Class files from library project missing in .apk

Postby jonbonazza » Sun Aug 29, 2010 8:41 pm

I am confused on what you mean by library project. a "library" in java is a collection of classes that can be reused and is imported into the build path of the particular project.... I think I am misunderstanding your terminology.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: Class files from library project missing in .apk

Postby grbrg » Sun Aug 29, 2010 9:57 pm

I'm not talking about Java libraries (Jar files), but Eclispe projects declared as "Android library". See the Android developer docs here: http://developer.android.com/guide/deve ... aryProject
grbrg
Developer
Developer
 
Posts: 34
Joined: Mon Jul 13, 2009 1:55 pm

Re: Class files from library project missing in .apk

Postby jonbonazza » Mon Aug 30, 2010 3:13 am

Oh... I have never done it that way. I have created many android libraries in the past, however I have always exported them as JAR files... That always worked for me...
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Top

Re: Class files from library project missing in .apk

Postby nachoburton » Thu Sep 09, 2010 11:26 pm

I'm having the exact same problem, but adding the link to the library src folder doesn't fix it. Any other ideas?
nachoburton
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Sep 09, 2010 11:23 pm

Re: Class files from library project missing in .apk

Postby adamwojciechowski111 » Sat Jan 22, 2011 6:09 pm

I had the same problem and here is a solution. Assume x is android project which uses y-lib android library project. In Eclipse go to x->properties->Android. If in Library box you can see a row with y-lib then remove it ("Remove" button) and add y-lib once again ("Add..." button). It will restore in classpath of x project with paths like y-lib_src_main_java (which you might have removed - like it was in my case)
adamwojciechowski111
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jan 22, 2011 6:02 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 15 guests