0

For my project, I would like to use the USB Serial For Android Library, from mik3y.

I tried to follow these step to link the library to my project, from Eclipse. But it won't work.

So I would like to know how to add this library through Android Studio.

Can you guide me please ?

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
Tofuw
  • 908
  • 5
  • 16
  • 35

2 Answers2

2

you can follow this way, to add library to android studio

  • Open your project in Android Studio.

  • Download the library (using Git, or a zip archive to unzip)

  • Go to File > Import Module and import the library as a module.
  • Go to File > Project Structure > Modules.
  • Locate your main project module, click on it. ...
  • Click on the more on the left green "+" button > Module dependency.

please visit this for more details.

Community
  • 1
  • 1
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
  • Thanks for your answer. It add the library as module. But now I have an error : 'Error:Application and test application id cannot be the same: both are 'com.hoho.android.usbserial.examples' for debugAndroidTest'. How can I solve it ? – Tofuw Jan 05 '16 at 10:24
  • My issue is not solved yet. I'm trying to understand the solution you give me above. Can you help me ? – Tofuw Jan 05 '16 at 10:47
  • in gradle file add this , applicationId 'com.abc.applicationname' – Amit Vaghela Jan 05 '16 at 10:54
  • Here is my defaultConfig application gradle : > 'defaultConfig { applicationId "com.polytech.projetco.monochromateur" minSdkVersion 19 targetSdkVersion 23 versionCode 1 versionName "1.0" } ' But I still have the same error – Tofuw Jan 05 '16 at 11:18
  • what you have written package in AndroidMenifest ? is both are same ? – Amit Vaghela Jan 05 '16 at 11:21
1

You can download the code source from Github and import the library as a module in Android studio.

  1. Download and extract the source code in a folder
  2. In android studio: File -> New -> Import module
  3. browse to the location when you extracted the library and select usbSerialForAndroid, then OK
  4. Let Android studio sync, you may need to do some changes in the buil.gradle file of the new module if you use different Android API
  5. Now, File -> Project Structure -> app -> dependencies -> add module dependencies and select your module
whd.nsr
  • 684
  • 6
  • 12