Add ZXing android project as a library in android studio

I am making an application in an Android studio that uses a barcode scanner. I am using google zxing lib. I downloaded zip, opened the project and added the core.jar file as instructed, but the tutorial was about eclipse and there is no way to add it to the library in android studio. so i'm stuck on how to add it. any help would be greatly appreciated :)

+6
source share
2 answers

Simple way with mvn repo:

dependencies { compile 'com.google.zxing:core:3.0.0' } 

More working version without mvn repo:

 dependencies { compile files('./libs/zxing/core.jar') } 

So, whichever version you choose, find the dependency block in build.gradle, and then add the appropriate compilation line. Remember to add it to build.gradle for your application module, not the root build.gradle.

Directory Layout Example: / Approot

/approot/build.gradle

/ approot / myfancyapp

/approot/myfancyapp/build.gradle <--- this one!

/approot/myfancyapp/libs/zxing/core.jar <--- putting a jar here or any path here is just an example.

+22
source

If you add compilation files ('libs / core.jar') to build.gradle, you will need to take another step: click the Sync project using the Gradle Files button on the toolbar.

0
source

All Articles