How to add serial port api as a library and use it in android studio?
<p>I am working on developing monitoring android app, using android studio. I would like to add android-serialport-api (<a href="https://code.google.com/p/android-serialport-api/" rel="nofollow noreferrer">https://code.google.com/p/android-serialport-api/</a>) as a library in my app and make serial communication possible in the project. I downlaod sources using SVN check out and using Cygwin. I was compiling NDK file and JNI File in serial port api then I copied all files and attached in the libraries file in my project. The project structure as below. </p>

<p><a href="https://i.stack.imgur.com/8p8hn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8p8hn.png" alt="Project structure"></a></p>

<p>and then I included the build.gradle file in android-serial-api like this.</p>

<pre><code>buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.12.+'
  }
 }
apply plugin: 'android-library'

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.2"

defaultConfig {

    minSdkVersion 15
    targetSdkVersion 23
}

sourceSets {
    main {
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']

        manifest.srcFile 'project/res/AndroidManifest.xml'
    }
}
</code></pre>

<p>}</p>

<p>I included this in app/build.gradle</p>

<pre><code>compile project(':libraries:android-serialport-api')
</code></pre>

<p>In settings.gradle I also included this. </p>

<pre><code>  include ':libraries:android-serialport-api'
</code></pre>

<p>androidmanifest.xml file is originally like this.</p>

<pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android_serialport_api.sample"
android:versionCode="3"
android:versionName="1.2" &gt;

 &lt;application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:name="Application" &gt;
&lt;activity
    android:label="@string/app_name"
    android:name="MainMenu" &gt;
    &lt;intent-filter &gt;
        &lt;action android:name="android.intent.action.MAIN" /&gt;

        &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
    &lt;/intent-filter&gt;
&lt;/activity&gt;
&lt;activity android:name="SerialPortPreferences" &gt;
&lt;/activity&gt;
&lt;activity android:name="ConsoleActivity" &gt;
&lt;/activity&gt;
&lt;activity android:name="LoopbackActivity" &gt;
&lt;/activity&gt;
&lt;activity android:name="Sending01010101Activity"&gt;&lt;/activity&gt;
&lt;/application&gt;



&lt;uses-sdk android:minSdkVersion="3" /&gt;

&lt;/manifest&gt;
</code></pre>

<p>However, when I make the project. there are lots of error. So erased most of the codes. so now androidmanifest.xml in library is like this. </p>

<pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="android_serialport_api.sample"
   android:versionCode="3"
   android:versionName="1.2" &gt;

&lt;uses-sdk android:minSdkVersion="3" /&gt;

&lt;/manifest&gt;
</code></pre>

<p>After erasing them, I can make the project and gradle sycronized. But I don't know how to use serial.c sources from library I imported. How can I fix the program? There are some messages in the todo list. </p>

<p>Please help me!!</p>