{"id":8085,"date":"2015-11-25T22:39:37","date_gmt":"2015-11-25T22:39:37","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/25\/how-to-integrate-zxing-library-to-android-studio-for-barcode-scanning-open-source-projects-zxing-zxing\/"},"modified":"2022-08-30T15:53:43","modified_gmt":"2022-08-30T15:53:43","slug":"how-to-integrate-zxing-library-to-android-studio-for-barcode-scanning-open-source-projects-zxing-zxing","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/25\/how-to-integrate-zxing-library-to-android-studio-for-barcode-scanning-open-source-projects-zxing-zxing\/","title":{"rendered":"How to integrate ZXing Library to Android Studio for Barcode Scanning?-open source projects zxing\/zxing"},"content":{"rendered":"<p>You need add the following to your <code>build.gradle<\/code> file:<\/p>\n<pre><code>repositories {\n    mavenCentral()\n\n    maven {\n        url \"http:\/\/dl.bintray.com\/journeyapps\/maven\"\n    }\n}\n\ndependencies {\n    \/\/ Supports Android 4.0.3 and later (API level 15)\n    compile 'com.journeyapps:zxing-android-embedded:2.0.1@aar'\n\n    \/\/ Supports Android 2.1 and later (API level 7), but not optimal for later Android versions.\n    \/\/ If you only plan on supporting Android 4.0.3 and up, you don't need to include this.\n    compile 'com.journeyapps:zxing-android-legacy:2.0.1@aar'\n\n    \/\/ Convenience library to launch the scanning and encoding Activities.\n    \/\/ It automatically picks the best scanning library from the above two, depending on the\n    \/\/ Android version and what is available.\n    compile 'com.journeyapps:zxing-android-integration:2.0.1@aar'\n\n    \/\/ Version 3.0.x of zxing core contains some code that is not compatible on Android 2.2 and earlier.\n    \/\/ This mostly affects encoding, but you should test if you plan to support these versions.\n    \/\/ Older versions e.g. 2.2 may also work if you need support for older Android versions.\n    compile 'com.google.zxing:core:3.0.1'\n}\n<\/code><\/pre>\n<p>My <code>build.gradle<\/code> file like this:<\/p>\n<pre><code>apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 21\n    buildToolsVersion \"21.1.2\"\n\n    defaultConfig {\n        applicationId \"com.myapplication2\"\n        minSdkVersion 16\n        targetSdkVersion 21\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\nrepositories {\n    mavenCentral()\n\n    maven {\n        url \"https:\/\/raw.github.com\/embarkmobile\/zxing-android-minimal\/mvn-repo\/maven-repository\/\"\n    }\n}\n\ndependencies {\n    compile fileTree(dir: 'libs', include: ['*.jar'])\n    compile 'com.android.support:appcompat-v7:21.0.3'\n    \/\/ Supports Android 4.0.3 and later (API level 15)\n    compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'\n\n    \/\/ Supports Android 2.1 and later (API level 7), but not optimal for later Android versions.\n    \/\/ If you only plan on supporting Android 4.0.3 and up, you don't need to include this.\n    compile 'com.embarkmobile:zxing-android-legacy:2.0.0@aar'\n\n    \/\/ Convenience library to launch the scanning and encoding Activities.\n    \/\/ It automatically picks the best scanning library from the above two, depending on the\n    \/\/ Android version and what is available.\n    compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'\n\n    \/\/ Version 3.0.x of zxing core contains some code that is not compatible on Android 2.2 and earlier.\n    \/\/ This mostly affects encoding, but you should test if you plan to support these versions.\n    \/\/ Older versions e.g. 2.2 may also work if you need support for older Android versions.\n    compile 'com.google.zxing:core:3.0.1'\n}\n<\/code><\/pre>\n<p>The code is here.<\/p>\n<p>Also, for how to use it, please refer my answer on the Stackoverflow here<\/p>\n<p>It contains method and also simple code that I have tested.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You need add the following to your build.gradle file: repositories { mavenCentral() maven { url &#8220;http:\/\/dl.bintray.com\/journeyapps\/maven&#8221; } } dependencies { \/\/ Supports Android 4.0.3 and later (API level 15) compile &#8216;com.journeyapps:zxing-android-embedded:2.0.1@aar&#8217; \/\/ Supports Android 2.1 and later (API level 7), but not optimal for later Android versions. \/\/ If you only plan on supporting Android [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-8085","post","type-post","status-publish","format-standard","hentry","category-zxing-library"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8085"}],"version-history":[{"count":2,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8085\/revisions"}],"predecessor-version":[{"id":9057,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8085\/revisions\/9057"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}