5

I am trying to use phonegap inside an android library project. The library project compiles just fine but when i try to start an activity that extends DroidGap, i get this error

01-02 10:12:17.575: W/dalvikvm(316): Unable to resolve superclass of Lcom/***/***.

I think this is because the phonegap.jar file is not included in the compiled jar file of the android library project. I have tried using ant to build but it doesn't seem to work.

Edit: I am building a android library that can be used in other android projects. I am using the standard android library project but activities in this lib project that extended DroidGap class in phonegap.jar are crashing with the above error.

Ashok
  • 227
  • 4
  • 10
  • check this out : http://stackoverflow.com/a/6859020/28557 – Vinayak Bevinakatti Jan 03 '12 at 07:11
  • 1
    seems like most people aren't grasping the fact that your external JAR is in the library project, and then when you try to reference your library project from another android project it can't see the JAR files that the library project is dependant upon - having similar issues myself only its more complicated because my JAR file is aJNI interface for some native C classes which I also want to share across multiple projects! – Dean Wild Mar 22 '12 at 12:51

6 Answers6

3

I´m afraid that is not possible yet. The result jar file will contain all classes and resources defined in the android library project, but will not include external jar files added to the build path. You will have to add those to your final Android Projects using that library. You can also find similar questions in SO like this one

Community
  • 1
  • 1
ggomeze
  • 5,711
  • 6
  • 29
  • 32
  • The linked question/answer explain in more detail. But basically, Shared Library projects are simple containers and wrappers. In the end, it just stuffs the source and resources into the consuming project; it does not copy in settings or library references, so those have to be copied in the consuming project manually. – Jon Adams May 08 '13 at 13:54
0

Try changing the name of the folder to libs instead of lib.

ajh158
  • 1,477
  • 1
  • 13
  • 32
  • The "libs" folder does automatically include JARs there in the project they are in. But still won't include them automatically if they are only in the shared project's libs directory. – Jon Adams May 08 '13 at 13:50
0

have you added required permission in manifest file.. see the below links

http://docs.phonegap.com/en/1.4.0/guide_getting-started_android_index.md.html

Emran Hamza
  • 3,829
  • 1
  • 24
  • 20
0

create one folder 'lib' in your project. put your .jar file in lib folder. select your .jar file right clicked on ,select buid path --->'add to build'. will add your .jar file. now you can use this .jar file classes.

Hiren Dabhi
  • 3,693
  • 5
  • 37
  • 59
  • I am already doing that but that doesn't seem to help. I think that works fine when you are dealing with a normal android project but including jar files in an android library project is not working. – Ashok Jan 02 '12 at 05:21
  • i have tested and am able to add and used phonegap library classes as above step. – Hiren Dabhi Jan 02 '12 at 05:27
  • There are two projects that i am using, one is an android project and the other is an android library project. I need to include phonegap.jar in the android library project. The android project uses the android library project and starts an activity in the android lib project, this seems to crash things. Are you doing the same, it this working for you? – Ashok Jan 02 '12 at 05:37
  • @Hiren Dabhi - see my comment on the original question – Dean Wild Mar 22 '12 at 12:56
0

I would suggest not making the 'lib' folder manually.

Instead:

Right click Project --> Properties --

  • Select Java Build Path

  • Make sure Libraries is the tab selected at the top

  • Click Add External JARs

Then find your JAR...

Basically, the same way you may have added the PhoneGap.jar

TryTryAgain
  • 7,632
  • 11
  • 46
  • 82
  • Are you suggesting not to link the android library project, but to the link the jar file created by the library project. I don't understand how that would help. I tried it out and it doesn't seem to help – Ashok Jan 02 '12 at 05:32
  • You'll have to edit your question and explain more with more specifics...I may not completely understand what you are trying to do. If you are linking to another library project that will still work, you would link that library and then add the PhoneGap.jar in the way I described. – TryTryAgain Jan 02 '12 at 05:39
0

The ADT (Android Development Tool Eclipse plug-in) has built-in support for the creation and reference of library projects. See the example in section 5 of this tutorial.

Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139