Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup alljoyn sdk in android?

I am trying to setup two android devices to communicate with each other through wifi. Some of the links I have gone through suggest alljoyn sdk in order to accomplish this.

There is an sdk download but there is no documentation for how to setup environment.

like image 673
harish.ooty-flashtoandroid Avatar asked Mar 18 '14 07:03

harish.ooty-flashtoandroid


1 Answers

Here is how to set up an AllJoyn SDK development environment with android studio:

  1. Download the SDK from this page. Go for Android Core SDK - release (or debug).
  2. Create a new blank android project.
  3. Create directory <project>/app/src/main/jniLibs and <project>/app/src/main/jniLibs/armeabi.
  4. From alljoyn-15.09.00-rel/java/jar copy alljoyn.jar and from alljoyn-15.09.00-rel/java/lib copy liballjoyn_java.so. The directory to copy from might differ depending on the current version and your release/debug choice.
  5. Put alljoyn.jar in /jniLibs and put liballjoyn_java.so in /jniLibs/armeabi. Should look like this

    enter image description here

  6. Right click project -> Open Module Settings -> app -> Dependencies.
    With the green [+] button, add a file dependency. enter image description here

    Navigate to <project>/app/src/main/jniLibs/alljoyn.jar and select that jar.

    This will add a line in your gradle (compile files('src/main/jniLibs/alljoyn.jar')) that will allow for code completion etc.

  7. In the file where you want to use alljoyn code, include this snippet

    /* Load the native alljoyn_java library. */
    static {
        System.loadLibrary("alljoyn_java");
    }
    

    for example:

    public class MainActivity extends AppCompatActivity {
        /* Load the native alljoyn_java library. */
        static {
            System.loadLibrary("alljoyn_java");
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            ...
        }
    }
    
  8. You can now use the alljoyn SDK. Import classes with

    import org.alljoyn.bus.BusAttachment;
    import org.alljoyn.bus.BusException;
    import org.alljoyn.bus.BusListener;
    

    etc.

If you're more of an eclipse guy, check this official documentation page on how to setup an eclipse environment.

like image 172
Tim Avatar answered Oct 25 '22 04:10

Tim