0

I am quite new to React Native but I need to create an Android Module for the Honeywell CT50 barcode scanner.

I have created a libs folder in MyApp/android/app as stated in these two SO posts:

Post 1

Post 2

The second post says I must then add the package name to the dependencies something like this:

dependencies {
   compile fileTree(dir: "libs", include: ["*.jar"])
   compile 'com.facebook.react:react-native:0.19.+'
   compile 'com.squareup.okhttp3:okhttp:3.4.1'
}

This the part I am struggling with, the formatting of the name. Here's what the contents of the .jar file looks like:

enter image description here

I would like to reference the AidcManager to do this I have tried:

compile "com.honeywell.aidc.AidcManager"
compile "com.honeywell.aidc:AidcManager"
compile "com.honeywell.aidc:"

Each time I get an error during my build saying something like:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.honeywell.aidc:AidcManager:.
 Searched in the following locations:
         file:/Users/XXX/.m2/repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
     file:/Users/XXX/.m2/repository/com/honeywell/aidc/AidcManager//AidcManager-.jar
     https://jcenter.bintray.com/com/honeywell/aidc/AidcManager//AidcManager-.pom
     https://jcenter.bintray.com/com/honeywell/aidc/AidcManager//AidcManager-.jar
     file:/XXX/node_modules/react-native/android/com/honeywell/aidc/AidcManager//AidcManager-.pom
     file:/XXX/node_modules/react-native/android/com/honeywell/aidc/AidcManager//AidcManager-.jar
     file:/Users/XXX/Library/Android/sdk/extras/android/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
     file:/Users/XXX/Library/Android/sdk/extras/android/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.jar
     file:/Users/XXX/Library/Android/sdk/extras/google/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
     file:/Users/XXX/Library/Android/sdk/extras/google/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.jar

Required by:
     MyApp:app:unspecified

Can anyone point me in the right direction? Many thanks in advance.

Community
  • 1
  • 1
mtwallet
  • 5,040
  • 14
  • 50
  • 74

2 Answers2

0

Just copy .jar files in libs folder and import classes or packages from it in your .java file. There is no need to reference them in .gradle file.

Dulmandakh
  • 21
  • 2
  • 3
    thanks for the reply. How would I import the classes into the .java file? Like this import com.honeywell.aidc.AidcManager ? – mtwallet Dec 15 '16 at 16:11
0

Answering wayyyyyyy to late, but might be helpful to others who are looking for this answer,

just add .jar in libs, then add below into gradle

implementation files('libs/<YourJarName>.jar')

Or

Right click the jar and select "Add jar to project" option

Pankaj
  • 1,242
  • 1
  • 9
  • 21