Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add ZXing android project as library in android studio

I am making an app in android studio that uses a bar code scanner. I am using the Google ZXing lib. I downloaded the zip, opened the project and added the core.jar file as instructed but the tutorial was for eclipse and there is no option to add as library in android studio. so I am stuck on how to add it. any help would be greatly appreciated :)

like image 362
Ryan95 Avatar asked May 09 '14 23:05

Ryan95


1 Answers

Simple way with mvn repo:

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

The more work version without mvn repo:

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

So whichever version you pick, look for the dependencies block in your build.gradle, then add in the appropriate compile line. Remember to add it into the build.gradle for your app module, not the root build.gradle.

Sample directory layout: /approot

/approot/build.gradle

/approot/myfancyapp

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

/approot/myfancyapp/libs/zxing/core.jar <--- put the jar here or any path, just an example.

like image 76
frederick_c_siu Avatar answered Nov 14 '22 22:11

frederick_c_siu