Search This Blog

Saturday, March 9, 2013

How to add Eneter Library into Android Project

Summary: Step-by-step procedure showing how to add Eneter library into your Android project in Eclipse.


Introduction

It seems there is a lot of confusion regarding adding an external library into the Android project.
If you use Eclipse and you add the library simply via 'Properties' -> 'Java Build Path' -> 'Libraries' then you can get into a state that you can build your Android application but when you upload it into the Android device it will not work and will be forced to close.

When you then check LogCat you may see errors like:
  • Could not find class ... or java.lang.ClassNotFoundException.
  • Failed resolving ...
The issue has already been discussed on stackoverflow too. And the same problem you can experience when you want to include eneter-messagin-android into your project.

How to add library into Android project

To add a library into the project you need to import it instead of adding it via project properties. Here is the procedure how to do it:
  1. Create a new folder libs in your project.
  2. Right click on 'libs' and choose 'Import...' -> 'General/File System' -> 'Next'.
  3. Then click 'Browser' button for 'From directory' and navigate to directory with eneter-messaging-android' library.
  4. Select check box for eneter-messaging-android.
  5. Press 'Finish'

10 comments:

  1. when running application on android i am getting error like this
    "Failed to send the message because it is not connected to any duplex channel "

    ReplyDelete
    Replies
    1. while my pc running is connected to internet via wifi router and android is also connected to same router.

      Delete
    2. The most common problem is that users change the IP address in the Android application but leave the 127.0.0.1 address in the desktop application.
      Both, Android client and desktop service must use the same real IP address.

      Also please meake sure there is no firewall on your PC blocking the incoming communication.

      Delete
  2. i have added library into Android project as u suggest but it error The import eneter cannot be resolved
    plz help me

    ReplyDelete
    Replies
    1. For the completeness here is the summary for this issue:
      1. The Eneter library must be imported to the folder 'lib' and not e.g. to the folder 'lib eneter'.
      2. There must be set correct Java compliance level 6.0 it means: Properties -> Java Compiler -> JDK Compliance -> 1.6

      Delete
  3. Do you have instructions for Android Studio?

    ReplyDelete
    Replies
    1. I have not tried Android Studio yet. I can do so and then update the procedure.

      Delete
    2. I got it to compile. I went into Project view, then found the libs folder. I copied eneter-messaging-6.0.1.jar into that folder in my OS. Then in Android Studio, I right clicked on it and made it an import.

      Delete
  4. I didn't get to work in Android Studio :(
    I include .jar file into project, and I got this error when try to compile project:
    "no main manifest attribute, in mypath.to..eneter-messaging-android-6.5.0.jar"

    Please Ondrey could you update procedure for Android studio ?

    Mladen

    ReplyDelete
    Replies
    1. Thank you for letting me know about the problem. I will update the procedure.

      Meanwhile, I googled little bit and maybe these links could help:
      http://stackoverflow.com/questions/22356181/how-to-resolve-the-android-studio-error-where-it-cannot-find-the-projects-manif

      http://stackoverflow.com/questions/27280742/no-main-manifest-attribute-error-after-add-volley-jar-library

      Delete